0

What does "Result: {0}" mean in the code?

do { Console.Write("x = "); int x = Convert.ToInt32(Console.ReadLine()); Console.Write("y = "); int y = Convert.ToInt32(Console.ReadLine()); int sum = x+y; Console.WriteLine("Result: {0}", sum); } while(true);

16th Sep 2021, 7:38 AM
Abdulwahab
Abdulwahab - avatar
2 ответов
+ 3
{0} acts like a placeholder and will be replaced by the given value which in your code is sum if no value provided it will act like a normal string
16th Sep 2021, 8:11 AM
Nima
+ 1
Thanks
27th Sep 2021, 10:31 AM
Abdulwahab
Abdulwahab - avatar