I am relatively new to programming but have noticed a lot of people when creating strings using variables do something like the below to put a variable into a string. I am curious at the difference/reason why this seems to be preferred by the senior developers I know and to also get opinions on why to use one over the other.
var x = "world";
Console.WriteLine("Hello {0}",x);
Is there an advantage or specific reason as to why the above is used as opposed to this:
var x = "world";
Console.WriteLine("Hello " + x);
Or this
var x = "world";
Console.WriteLine($"Hello {x}");
Console.WriteLine(GreetingPlaceholder, x);
andConsole.WriteLine(GreetingPrefix + x);
if you want to support multiple languages