Does C# use #pragma strict?

I’ve noticed I see #pragma in JavaScript but don’t think I’ve seen it in C#. Is this a Java only thing? When I’m adapting a script from Java to C#, I should omit #pragma strict?

Actually, no. The C# compiler doesn’t understand the pragma “strict”. The MS C# compiler actually only understands two pragmas. Not sure if the Mono compiler has any additional ones but “strict” certainly isn’t one of them. Unknown pragmas are usually ignored, however to keep the code clean you shouldn’t add it to a C# script.

Like Eric already said JavaScript is not Java. You really shouldn’t confuse those two languages. Java has no relation to Unity at all (with the small exception of Android since android apps run in a Java VM). Unity’s JavaScript is actually called UnityScript (internally and more and more externally as well). UnityScript just has a JavaScript-like-syntax but is actually a complete seperate language. Unity called it “JavaScript” only for marketing purposes ^^

As far as I can tell C# does not support #pragma strict. See reference here.

C# by nature uses strong typing. Though you can still use the var type to tell the compiler to infer the type.