将两个数字的和输出到控制台
本文关键字:输出 控制台 数字 两个 | 更新日期: 2023-09-27 17:59:01
我正在尝试获取两个数字的和,但显示不正确。这是代码:
int number1 = 1;
int number2 = 3;
Console.Write("The sum of " number1 "and" number2 "is" total ".");
试试这个:
Console.Write("The sum of {0} and {1} is {2}.", number1, number2, total);
试试这个:
Console.Write("The sum of " + number1 + " and " + number2 + " is " + total +".");
您需要+
运算符将字符串连接在一起。