How does one fix that the feature isn’t in C# 4… Hmm Not sure you can.
Re-write it so you don’t require that operator is what I’d do, until if/when it’s properly supported in Unity.
Is there any documentation where I can see a) what .NET framework versions are supported b) which C# version is supported?
Can’t find a way to get this information from anywhere…
Unity targets .Net 3.5 with C# version 4 by default (well technically .net 2.0, but has ‘most’ features up to 3.5).
The latest version allows you go into the player settings and target .Net 4.6 with C# version 6 if you’d like. This was experimental for the last year, and I think the newest version of unity has it just now out of experimental (some one correct me if I’m wrong, I currently only run 5.6.3f1 and 2017.4).
To know what is supported by the .Net version, when going through the MSDN for .net just make sure you restrict to the version of .Net you’re attempting to stick with. Though keep in mind that since unity uses mono, and you’re cross platform, this is still limited. The documentation starts here:
As for C# language features, like ‘null propagating operator’, you’ll need to consult the language version history. Here is an MSDN article on it, and you should consult MSDN at large for most of this information as the C# standard is defined by Microsoft and not by Unity:
The general rule is… if the syntax feature was available when the .net version was released, then it’s generally supported. As a result most people don’t really keep track of the C# language version and usually refer to things as to what .net version they’re targeting.
And of course… if your compiler says it’s not supported. Well don’t use that syntactical feature.
That is not true, this is a very popular operator in modern languages, Swift (optionals), JavaScript, Kotlin and now C# 4.
It makes code shorter and easier to read and understand.