I have some template string
this is my {0} template {1} string
which I plan to put user values in using String.Format()
.
The string actually is longer so for readability I use:
this is my {goodName1} template {goodName2} string
And then String.Replace
each parameter with its value.
How can I get the highest performance and readability?
Maybe I should not have this template in a file (as now) but dynamically build it by concatanating to a string builder and adding the params when required? Although it's less readable.
What's my other options?
From Atwood: It. Just. Doesn't. Matter.
The same thing above that Fredrick posted above, but with linq.
If you need a good, fast, but simple template engine, you should check out StringTemplate. For simple templates that don't require any logic or flow control in the template itself, StringTemplate is GREAT.
http://www.stringtemplate.org/download.html