0

when would you use this? C#

I just started learning C# yesterday and I left off at the console playground. it teaches you that when typing: static void Main(string[] args) { int x = 10; double y = 20; Console.WriteLine("x = {0}; y = {1}", x, y); } // Output: x = 10; y = 20 you will output x = 10; y = 20. I have played with this a bit and got: Console.WriteLine("{0} {1}", x, y); and it types out 10 20. when would you use this?

7th Jul 2020, 1:10 PM
Samuel Payne
Samuel Payne - avatar
1 Réponse
+ 3
String formating is a succinct syntax, to shorten the old syntax such as "The variable is " + variable.
7th Jul 2020, 1:35 PM
Gordon
Gordon - avatar