I am trying to isolate (for localization purposes) the formatting of some messages. In one case, I have several parameters, some of which may be an empty string. An example is probably called here ....
If the parameters are Parameter 1 and Parameter 2, then I want the result to be Some message Parameter one (Parameter 2).
If the parameters are Parameter 1 and String. Then, I want the result to be Some message Parameter one
If parameter 2 was a numeric value, I could use something like:
String.Format("Test {0}{1:' ('#')'}", "Parameter one", 12);
This works the way I expected - especially if the second parameter is zero, the output is only test parameter 1.
Unfortunately, I have not yet found a similar option that works with string parameters. There is one?
Clarification: I am fully aware of the many ways to get the result that I need in the code. I specifically want to know if there is a similar built-in mechanism for strings for the numeric one shown above.
string c # formatting
Richard J Foster
source share