我只是试图使用DateTime
结构将1到12之间的整数转换为abbrieviated月份名称。将月份int转换为月份名称
这里是我的尝试:
DateTime getMonth = DateTime.ParseExact(Month.ToString(),
"M", CultureInfo.CurrentCulture);
return getMonth.ToString("MMM");
但是我得到了FormatException
第一线,因为该字符串不是一个有效的DateTime
。谁能告诉我如何做到这一点?
'GetAbbreviatedMonthName()'似乎是适当的。 – 2011-06-09 00:43:54
与此相反的是什么?输入月份名称并取回数字? – 2016-10-27 13:56:39
'int month = DateTime.ParseExact(MonthNameValue,“MMMM”,CultureInfo.CurrentCulture).Month' – CharithJ 2016-10-28 02:55:53