c# First Monthletter in uppercase
我显示的月份名称如下:
String.Format("{0:MMMM}", DateTime.Now)
但是,使用瑞典语时,所有月份名称均为小写。
格式化日期时是否有一些巧妙的技巧可以将首字母变为大写?或者我必须为其编写一个函数?
I'm displaying a month name like this:
String.Format("{0:MMMM}", DateTime.Now)
However, when using Swedish all month names are in lowercase.
Is there some neat trick to make first letter uppercase when formatting dates? Or do I have to write a function for it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议克隆一种文化并在其中重新定义一个新的月份名称:
然后在
string.Format
方法中使用它:为了使月份大写,我使用
TextInfo.ToTitleCase
方法。I'd suggest to clone a culture and re-define a new month names in it:
and then use it in
string.Format
method:To make months in upper case I use
TextInfo.ToTitleCase
method.这里已经有一些很好的答案。如果你想要一个函数,你可以写:
There are some good answers here already. If you want a function you can write: