将句子的第一个字母转换为大写字母 [英] Convert first letter of a sentence to caps
本文介绍了将句子的第一个字母转换为大写字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想从一组单词中打印第一个写入大写的字母,当我尝试使用vbpropercase时,它会转换每个单词的第一个字母资本。但我不希望这样。
例如,运输公司
应打印为运输公司而非运输公司
>
尽快帮助。
提前致谢。
Hi All,
I want to print the very first letter to capital from a group of words, when i try with vbpropercase it converts first letter of each word to capital. But i do not want that.
Eg., shipping company
should be printed as Shipping company instead of Shipping Company
Help ASAP.
Thanks in advance.
推荐答案
>
看看这里:
http://www.daniweb.com/software-development/vbnet/threads/369426/text-cases-in-vb.net [ ^ ]
转到''句子''
Hi,
Have a look here:
http://www.daniweb.com/software-development/vbnet/threads/369426/text-cases-in-vb.net[^]
Go to ''Sentence Case''
private string FirstLetterToUpper(string word)
{
StringBuilder sb = new StringBuilder();
if (!string.IsNullOrWhiteSpace(word))
{
sb.Append(word.Substring(0, 1).ToUpper());
sb.Append(word.Substring(1, word.Length - 1));
}
return sb.ToString();
}
这篇关于将句子的第一个字母转换为大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文