سؤال

I am trying to get the sum of two numbers, but it is not displaying correctly. Here is the code:

int number1 = 1;
int number2 = 3;

Console.Write("The sum of " number1 "and" number2 "is" total ".");
هل كانت مفيدة؟

المحلول 2

try this:

Console.Write("The sum of " + number1 + " and " + number2 + " is " + total +".");

You need the + operator to concatenate string together.

نصائح أخرى

Try this:

Console.Write("The sum of {0} and {1} is {2}.", number1, number2, total); 
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top