Is it possible to specify some kind of flag or modifier on a string format param to make it lower case or upper case?
Example of what I want:
String.Format("Hi {0:touppercase}, you have {1} {2:tolowercase}.", "John", 6, "Apples");
Wanted output:
Hi JOHN, you have 6 apples.
PS: Yes I know that I can change the case of the param before using it in the string format, but I don’t want this.
There’s only padding and allignment formating… So the easy way is like you said, use
"John".ToUpper()or"John".ToLower().Another solution could be create a custom
IFormatProvider, to provide the string format you want.This is how will look the
IFormatProviderand the string.Format call.And the call will look like: