String Formatting with concatenation or substitution
- by Davio
This is a question about preferences.
Assume a programming language offers these two options to make a string with some variables:
"Hello, my name is ". name ." and I'm ". age ." years old."
StringFormat("Hello, my name is $0 and I'm $1 years old.", name, age)
Which do you prefer and why?
I have found myself using both without any clear reason to pick either.
Considering micro-optimizations is not within the scope of this question.
Localization has been mentioned as a reason to go with option #2 and I think it's a very valid reason and deserves to be mentioned here.
However, would opinions differ based on aesthetic viewpoints?