把整成C#中的月份名称的最好方法? [英] Best way to turn an integer into a month name in c#?

查看:162
本文介绍了把整成C#中的月份名称的最好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有把整成.NET的月份名称?

Is there a best way to turn an integer into its month name in .net?

很显然,我可以旋转起来日期时间串并分析当月的名字在那里。这似乎只是时间的巨大浪费。

Obviously I can spin up a datetime to string it and parse the month name out of there. That just seems like a gigantic waste of time.

推荐答案

从的DateTimeFormatInfo尝试GetMonthName

Try GetMonthName from DateTimeFormatInfo

<一个href="http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.getmonthname.aspx">http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.getmonthname.aspx

您可以做到这一点:

CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1);

这篇关于把整成C#中的月份名称的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆