c#索引超出了数组界限hour = Convert.ToInt32(strList[1]);
privateDateTimeGetDateTime(DateTimeymd,stringhm){inthour=0;intminute=0;if(ymd!=null){...
private DateTime GetDateTime(DateTime ymd, string hm)
{
int hour = 0;
int minute = 0;
if (ymd != null)
{
string[] strList = hm.Split(',');
DateTime vacationTime = new DateTime();
switch (strList.Length)
{
case 0:
vacationTime = new DateTime(ymd.Year, ymd.Month, ymd.Day);
break;
case 1:
hour = Convert.ToInt32(strList[1]);//索引超出了数组界限
vacationTime = new DateTime(ymd.Year, ymd.Month, ymd.Day, hour, minute, 0);
break;
case 2:
hour = int.Parse(strList[1]);
minute = int.Parse(strList[2]);
vacationTime = new DateTime(ymd.Year, ymd.Month, ymd.Day, hour, minute, 0);
break;
default:
break;
}
}
各位大牛,这是为什么吖 展开
{
int hour = 0;
int minute = 0;
if (ymd != null)
{
string[] strList = hm.Split(',');
DateTime vacationTime = new DateTime();
switch (strList.Length)
{
case 0:
vacationTime = new DateTime(ymd.Year, ymd.Month, ymd.Day);
break;
case 1:
hour = Convert.ToInt32(strList[1]);//索引超出了数组界限
vacationTime = new DateTime(ymd.Year, ymd.Month, ymd.Day, hour, minute, 0);
break;
case 2:
hour = int.Parse(strList[1]);
minute = int.Parse(strList[2]);
vacationTime = new DateTime(ymd.Year, ymd.Month, ymd.Day, hour, minute, 0);
break;
default:
break;
}
}
各位大牛,这是为什么吖 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询