+ 1
C# which notation is better
$@"{sth here}/sth here" or String.Format("{0}/sth here", sth here)?
2 Respuestas
+ 2
There is no better, it is just personal preference.
The $ should be easier to read and make you look young
I have to admit, I prefer the {0} since I have use it for so long.
So {0} make you look old or should I say more experienced.
please remove the space between "sth" and "here".
"sth here" is not a valid integer.
string sthhere = "hello";
Console.WriteLine($@"{sthhere}/sth here");
Console.WriteLine(String.Format("{0}/sth here", sthhere));
+ 6
@sneeze was correct as it's just a syntactic sugar. Just pick one that you find easier to read and you'll be fine.
P/S: The @ is superfluous in this case as it's used for verbatim string to simplify escape characters. 😉