c# - Unity 5.5.2f1 到 5.6.1f1 - 内插字符串错误?

标签 c# unity3d c#-4.0

我刚刚将我的 Unity 版本从 5.5.2f1 更新到 5.6.1f1。突然我得到错误:

Feature `interpolated strings' cannot be used because it is not part of the C# 4.0 language specification

下面的代码在更新之前运行良好。

public class SensorData
{
    public int Timestamp { get; set; }
    public float Humidity { get; set; }
    public float Temp { get; set; }
    public int Light { get; set; }
    public int Button { get; set; }

    public override string ToString()
    {
        return $"{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}";
    }
}

我不知道它是否应该仍然有效。

最佳答案

似乎更新后插值字符串仍然不起作用。为了仍然使用上面提到的代码,我采用了旧方法。

代替:

return $"{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}";

我做了:

return string.Format ("{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}", Timestamp, Humidity, Temp, Light, Button);

关于c# - Unity 5.5.2f1 到 5.6.1f1 - 内插字符串错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44107248/

相关文章:

android - Android Studio 能否用于从库项目中创建与 Unity 插件兼容的 JAR?

c# - OmniSharp 自动完成类名,而不仅仅是方法/属性?

c#-4.0 - 使用 Microsoft PowerShell 编辑 Web Config 文件

c# - 通过条件乘以其他两个两个数组来调整数组的长度

c# - gameObject 的多个实例表现不尽相同

c# - 复制文件和文件夹,保留 Windows 7 界面

c# - 无法启动程序,Windows Web 服务框架中出现无法识别的错误

c# - 自定义字体 Monodevelop

javascript - JSON.NET 抛出 'additional text found in JSON string after finishing deserializing object."

c# - 将位数组转换为字符串