Tuesday, April 1, 2014

Why bother with this format {0}, varName?

New to Visual Studio and it's been 7 years since I've done any C#.


So the question I have is why bother with this format for a string output, what is going on with it and whats the benefit of it?



string tempValue = "Hello World";
Console.Write("Value of tempValue = {0}", tempValue);



Why would I use the above and not just call



string tempValue = "Hello World";
Console.Write("Value of tempValue = " + tempValue);

I'm looking for clarity as to why I would bother with the first code snippet.

No comments:

Post a Comment