gpt4 book ai didi

C# 6.0 - 意外字符 '$'

转载 作者:太空狗 更新时间:2023-10-29 20:06:56 26 4
gpt4 key购买 nike

<分区>

我是编程新手,我刚刚安装了 Visual Studio 2017。我创建了这段代码(来 self 正在学习的书),但它无法编译。我在字符串插值方面遇到问题并且出现错误:

Unexpected character '$',

但我使用的是 C# 6.0,所以这应该不是问题?

static void Main(string[] args)   
{
string comparison;
WriteLine("Enter the number:");
double var1 = ToDouble(ReadLine());
WriteLine("Enter another number :");
double var2 = ToDouble(ReadLine());
if (var1 < var2)
comparison = "less than";
else
{
if (var1 == var2)
comparison = "equal to";
else
comparison = "greater than";
}

WriteLine($ "The first number is {comparison} the second number");
ReadKey();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com