我有一个包含短月份名称的字符串。\
string month = "Jun";
我需要从这个月份的名称中获取月份的数字。
假设我这样做:
int monthInDigit = getMonth(month);
monthInDigit <-- 6
我怎样才能做到这一点。如果您不能回答我的问题,请发表评论,我会妥善解释。
提前致谢
最佳答案
int monthInDigit = DateTime.ParseExact(month, "MMM", CultureInfo.InvariantCulture).Month;
关于c# - 将包含 monthName 的字符串转换为 MonthDigit 的 Int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19220249/