Does Unity use a different version of C#, or is it all the same? It looks different from regular C# but there are some regular C# elements in there.
As stated in other answers Unity 4.x uses a modified version of Mono based on Mono 2.6
For the most part, this is compatible with the .Net 2.0, though I haven't managed to track down a Mono 2.6 specific compatibility list.
It looks different from regular C# but there are some regular C# elements in there.
As mentioned in one of the comments on your question, this is likely due to Unity's particular scripting API rather than the language itself.
As an example, a lot of code in a typical Unity projects is contained in subclasses of a class called MonoBehavior. These are components that are dropped on GameObjects within the Unity Editor environment. This architecture leads to C# code that looks different to typical C# code (to me anyway) in a number of ways:
- Until Unity 4 was released, these objects could not be contained in namespaces, so they're always in the global namespace
- They expose fields to the editor environment by making them public (or by using the SerializeField attribute, but I find very few people use this), which leads to an unusually large number of public fields on classes
- Unity's privacy and case conventions don't follow Microsoft's, so this can also look strange to a "traditional" C# developer
- They make use of a number of special methods on these components, such as Start and Update, that are not overrides as one would typically expect, but are accessed by means of reflection instead.
Practically speaking, the biggest C# language feature I miss in Unity's current C# version is support for async and related keywords and functionality. A similar concept in Unity is coroutines. These execute on the main thread so aren't true async, but do allow long running code to be broken up over multiple frames. Lower level multithreading is still supported.
I'm not sure how it looks different, but keep in mind that Unity supports several languages, all of which work on top of the same Mono runtime. Is it possible you're confusing C# with UnityScript?
Unity uses regular C#.
Then again, when you write C# in Unity you will be using a lot of their libraries, but as far as I know, everything possible in C# is possible in Unity, other than the differences listed below:
More specific areas of .Net relating to Windows Forms & ASP are off limits through Unity.
While you can use Visual Studio for editing and compile-time errors, you have to build and run in the Unity IDE.
Unity uses Mono which is an open source implementation of .Net which means there are slight differences.
The question whether the C# Version used by Unity is different from a "regular" C# has been answered by other posts. Since you are explicitly asking for certain elements which might differ from such a regular version I will share the only minor difference I noticed when comparing the C# I use at work (i.e. C# 4.0 in Visual Studio 2010 and higher) and C# in Unity,
which is that I can't use default values for parameters in function definitions. which is that you have to set up your project more carefully in order to use a newer version of C#. See this link for further explanation.
Edit: I leave this answer since as far as I know this is a misunderstanding that happens to quite a lot of people.
protected by Josh♦ Jul 15 '14 at 20:29
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?