[英]How to print Text and value from integer on the same line in the console?
这是我所做的,但没有奏效:
int money;
Console.Writeline("Enter how much money you want";
money=int.Parse(Console.ReadLine());
Console.Writeline("The Money you have now are",money)
您有多种选择:
连接字符串:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.