Console.Writeline - Why there is no way out

An absolute beginner in C #. I tried to run this program, and the output would simply not show any calculations. Why? I did not want to go through p, q, r, s to add, sub, multiply, divide, etc. Also, how can I put a space between "Please enter a number" and username?

string userName;
double  x, y;

Console.WriteLine(" Enter Your Name ");
userName = Console.ReadLine();
Console.WriteLine(" Please Enter A Number "+ userName);
First = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please Enter Another Number"+ userName);
Second = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The addition of Two Numbers is",x,y, x*y);
Console.WriteLine("The substraction of Two Numbers is",x,y,x/y);
Console.WriteLine("The multiplication of Two Numbers is",x,y,x * y);
Console.WriteLine("The division of Two Numbers given is", x,y,x / y);
Console.ReadKey();
+4
source share
2 answers

When you pass additional parameters for output, you must tell WriteLinewhere to put it by adding placeholders to the format string, for example:

Console.WriteLine("The product of Two Numbers {0} and {1} is {2}", x, y, x*y);

. (.. x) {0}; y {1}, x*y {2} .

, userName, , :

Console.WriteLine("Please Enter Another Number " + userName);

userName to "Please Enter Another Number" WriteLine. , :

Console.WriteLine("Please Enter Another Number {0}", userName);
+11

dasblinkenlight. ,

Console.WriteLine("{0}, {1}", "Hello", 53);

: Hello, 53. {0} , {1} . .NET - http://msdn.microsoft.com/en-us/library/txafckwd%28v=vs.110%29.aspx

0

Source: https://habr.com/ru/post/1569869/


All Articles