Monday, July 16, 2018

c# - Why doesn't my C#6 code compile in Unity?


Why can't Unity work with C# 6 code? It always gives me compiler errors. Here are some code examples:


using static System.Convert;
using static System.Environment;

$"€{punten}{NewLine}€{Money}{NewLine}€{KilledEnemies}{NewLine}€{bonus}{NewLine}€{total}";

I use Visual Studio as my code editor and build with no errors. If I press play in Unity it won't build.




Answer



Unity uses an old version of Mono runtime which is based on .NET3.5. It uses something between C# 3 and 4 in terms of features.


I found this by googling around. Not sure if it works but might be something worth investigating.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...