MSDN:TextInfo.ToTitleCase
确保您包括:
using System.Globalization
string title = "war and peace";TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;title = textInfo.ToTitleCase(title); Console.WriteLine(title) ; //War And Peace//When text is ALL UPPERCASE...title = "WAR AND PEACE" ;title = textInfo.ToTitleCase(title); Console.WriteLine(title) ; //WAR AND PEACE//You need to call ToLower to make it worktitle = textInfo.ToTitleCase(title.ToLower()); Console.WriteLine(title) ; //War And Peace
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)