将字符串转换为标题大小写

将字符串转换为标题大小写,第1张

字符串转换为标题大小写

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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5499081.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存