本文介绍了仅将字符串的首字母大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看过这样的帖子了:
I have already taken a look at such posts like:
格式化为首字母大写 如何大写每个字母的首字母字符串中的单词
但是这些似乎都不起作用.我首先想到的是:
But none of these seem to actually work. I would of thought to start with that there would just be a:
.Capitalize();就像那里一样:
.Lower(); & .Upper();有人可以给我有关转换为类似字符串的任何文档或参考吗?
Could anyone possibly give me any documentation or references regarding converting to a string like:
string before = "INVOICE";然后成为:
string after = "Invoice";我使用我所阅读的帖子解决方案给我的方式没有收到任何错误,但是,之前仍然保持为大写.
I receive no errors using the way the posts solutions I read give me, however, the before still remains Capitalized.
推荐答案在第一个字符上使用 ToUpper ,在其余字符串上使用 ToLower 怎么样?
What about using ToUpper on the first char and ToLower on the remaining string?
string after = char.ToUpper(before.First()) + before.Substring(1).ToLower();更多推荐
仅将字符串的首字母大写
发布评论