Is there a “simple” way to capitalize a single char-typed value?
This will work, but feels cumbersome and generally wrong:
var ch = 'a';
var cap = ("" + ch).ToUpper()[0];
cap.Dump(); // (in LINQPad) => 'A'
Notes:
- The choice of
"" + choverToString()is because ReSharper yells at me for not specifying a culture with the latter … in any case,ch.ToString().ToUpper()[0]feels just as cumbersome. - For the sake of globalization, just “adding 32” is not an option; I do not believe there is any single
charthat turns into a surrogate-pair when capitalized.
Thanks,
should do the job.