我该如何利用C#中第一个名字的第一个字母和最后一个名字吗? [英] How do I capitalize first letter of first name and last name in C#?
本文介绍了我该如何利用C#中第一个名字的第一个字母和最后一个名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种简单的方法来利用一个字符串的第一个字母,降低它的休息吗?是否有一个内置的方法或做我需要让我自己?
Is there an easy way to capitalize the first letter of a string and lower the rest of it? Is there a built in method or do I need to make my own?
推荐答案
使用 System.Globalization.TextInfo.ToTitleCase()
,其中大写字符串中的每一个字:
Use System.Globalization.TextInfo.ToTitleCase()
, which capitalizes every word in the string:
string text = "john doe";
string result = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
// Produces "John Doe"
另请参阅 MSDN链接进行了详细的描述。
这篇关于我该如何利用C#中第一个名字的第一个字母和最后一个名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文