我试图得到两个数字的总和,但它没有正确显示。这是代码:
int number1 = 1;
int number2 = 3;
Console.Write("The sum of " number1 "and" number2 "is" total ".");
答案 0 :(得分:6)
试试这个:
Console.Write("The sum of {0} and {1} is {2}.", number1, number2, total);
答案 1 :(得分:2)
试试这个:
Console.Write("The sum of " + number1 + " and " + number2 + " is " + total +".");
您需要+
运算符将字符串连接在一起。