这就是我的工作,但它没有工作:
int money;
Console.Writeline("Enter how much money you want";
money=int.Parse(Console.ReadLine());
Console.Writeline("The Money you have now are",money)
答案 0 :(得分:6)
您有几种选择:
连接字符串:
Console.Writeline("The Money you have now are" + money);
使用Console.WriteLine
的格式说明符版本:
Console.Writeline("The Money you have now are: {0}", money);
改为使用Console.Write
:
Console.Write("The Money you have now are: ");
Console.Writeline(money);
由于缺少括号,分号和不正确的大小写,您的代码实际上并未编译。我会把你的代码写成:
Console.WriteLine("Enter how much money you want");
int money = int.Parse(Console.ReadLine());
Console.WriteLine("The Money you have now is {0}", money);
答案 1 :(得分:0)
从C#6开始,这可以写成:
Console.Writeline($"The Money you have now are: {money}");