在不使用if-else子句12次的情况下执行此任务的最佳方法是什么.任务是这样的:
if(mon=="1")
{
month="JAN";
}
else if(mon=="2")
{
month="FEB";
}
Run Code Online (Sandbox Code Playgroud)
等等..
Pre*_*ngh 14
尝试使用此代码
using System.Globalization;
var month = 7;
var dtf = CultureInfo.CurrentCulture.DateTimeFormat;
string monthName = dtf.GetMonthName(month);
string abbreviatedMonthName = dtf.GetAbbreviatedMonthName(month);
Run Code Online (Sandbox Code Playgroud)