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.
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed. |
|||||||||||||||||
|
Unity 4 uses Mono 2.6, which is a full implementation of the .NET framework, including the C# language. 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:
|
|||||
|
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.
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:
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. |
|||
|
Some elements of the UnityEngine package conflict with standard C# naming, so it makes it appear to be different. However, as others have said, it is regular C#. |
|||
|
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, 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 Petrie♦ Jul 15 at 20:29
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?