How to Capitalize names

前端 未结 9 1827
余生分开走
余生分开走 2020-12-15 02:46

so basically if i want to transform a name from

stephen smith 

to

Stephen Smith

i can easily do it with c

9条回答
  •  醉话见心
    2020-12-15 03:17

    You can do this using the ToTitleCase method of the System.Globalization.TextInfo class:

    CultureInfo cultureInfo   = Thread.CurrentThread.CurrentCulture;
    TextInfo textInfo = cultureInfo.TextInfo;
    
    Console.WriteLine(textInfo.ToTitleCase(title));
    Console.WriteLine(textInfo.ToLower(title));
    Console.WriteLine(textInfo.ToUpper(title));
    

提交回复
热议问题