I\'ve just updated my Unity version from 5.5.2f1 to 5.6.1f1. Suddenly I get the error:
Feature `interpolated strings\' cannot be used because it is n
In Unity 2017 it's now possible to use interpolated strings in Unity if you change the .NET version that Unity uses. Interpolated strings is a feature from C# 6 which is released in .NET 4.6.
To change to .NET 4.6 go to:
Edit > Project Settings > Player
, expand "Other settings" and change the "Scripting Runtime Version" to .NET 4.6
For more info look at: https://docs.unity3d.com/Manual/ScriptingRuntimeUpgrade.html
In Unity 2018, Unity should use .NET 4.x by default so you should have access to interpolated strings without having to change anything.
It seems that interpolated strings are still not working after updating. To still use my above mentioned code, I did it the old way.
Instead of:
return $"{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}";
I did:
return string.Format ("{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}", Timestamp, Humidity, Temp, Light, Button);
I have had success using
string.format("{0},{1},{2},{3}, {4}", Timestamp, Humidity, Temp, Light, Button);