在c#中将整数转换成月名的最佳方法? [英] Best way to turn an integer into a month name in c#?

查看:84
本文介绍了在c#中将整数转换成月名的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



显然,我可以旋转一个datetime来对其进行字符串并解析月份名称在那里这只是一个巨大的浪费时间。

解决方案

从DateTimeFormatInfo尝试GetMonthName



http://msdn.microsoft.com /en-us/library/system.globalization.datetimeformatinfo.getmonthname.aspx



您可以通过以下操作:

  CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1); 


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.

解决方案

Try GetMonthName from DateTimeFormatInfo

http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.getmonthname.aspx

You can do it by:

CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1);

这篇关于在c#中将整数转换成月名的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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