//我相信LZ更不愿意这样写:
string constellation;
switch(month_day)
{
case:"0321":
case:"0322":
...
case:"0420":constellation="白羊";break;
case:"0421":
case:"0422":
...
case:"0521":constellation="金牛";break;
...
}
//有必要一定要用switch吗?
string constellation;
switch(month_day)
{
case:"0321":
case:"0322":
...
case:"0420":constellation="白羊";break;
case:"0421":
case:"0422":
...
case:"0521":constellation="金牛";break;
...
}
//有必要一定要用switch吗?
//我相信LZ更不愿意这样写:
string constellation;
switch(month_day)
{
case "0321":
case "0322":
...
case "0420":constellation="白羊";break;
case "0421":
case "0422":
...
case "0521":constellation="金牛";break;
...
}
//有必要一定要用switch吗?
if(x>321&& x<420)
{
.....
}
else if(...)
{
.....
}
......
int monthDay = int.Parse("0609");
int month = month / 100;
int day = month % 100;
switch (month)
{
case 3: result = (day < 21) ? enumHoroscope.Pisces : enumHoroscope.Aries; break;
}
int monthDay = int.Parse("0609"); // try+catch
int month = monthDay / 100; // 1~12?
int day = monthDay % 100; // 1~31? Feb 30? Apr 31?
switch (month)
{
case 3: result = (day < 21) ? enumHoroscope.Pisces : enumHoroscope.Aries; break;
}