C#: parametrized string with spaces only between "full" parameters? -
I want to output a string that welcomes the user to the application. I have the user's first, middle and last name I would like to enter the full name of the user, i.e. "hello {0} {1} {2}"
with first, middle and last parameters, however, if the middle name is empty, There should not be two places between names, but rather only one place. I can explicitly do this with "if", but is there another great way to achieve this?
Thanks
string.format ("{0} {1 } {2} ", first, middle, final). Change ("", "")
Comments
Post a Comment