Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • String interpolation is just syntax sugar. I am not sure about your needs, but did you think about this scenario ? 1.) know what tokens/ placeholders you have in template; 2.) Pass template, found tokens, data packed in Dictionary<Token, TokenValue> into factory 3.) Iterate over found tokens and replace placeholders template.Replace(tokenItem, tokensData[tokenItem].Value) Commented May 20, 2019 at 15:17
  • Both approaches share the same problem for human edits: if it's multiple indexes, then human can screw up with numbers; if it's name, then human may screw up with letter and type it as nmae. I'd keep using old good {0} and will simply split long ones into several simpler, e.g. instead of "Good day {0}, would you like to do {1}" I'd make two sentences. And, well, you can still screw up even with {0}. Commented May 20, 2019 at 15:52