在开发网络社区中,有时会常用到生肖这个功能,以下是把一个人的出生年月转成对应的生肖功能
/// <summary>
/// Gets the name of the SNET member zodiac chinese.
/// </summary>
/// <param name="birthdayYear">The birthday year.</param>
/// <returns></returns>
public static string GetSNETMemberZodiacChineseName(DateTime birthdayYear)
{
int i = birthdayYear.Year%12;
switch(i)
{
case 4:
return "鼠";
break;
case 5:
return "牛";
break;
case 6:
return "虎";
break;
case 7:
return"兔";
break;
case 8:
return"龙";
break;
case 9:
return"蛇";
break;
case 10:
return"马";
break;
case 11:
return"11";
break;
case 0:
return"猴";
break;
case 1:
return"鸡";
break;
case 2:
return"狗";
break;
case 3:
return"猪";
break;
}
return "";
}
/// <summary>
/// Gets the name of the SNET member zodiac chinese.
/// </summary>
/// <param name="birthdayYear">The birthday year.</param>
/// <returns></returns>
public static string GetSNETMemberZodiacChineseName(DateTime birthdayYear)
{
int i = birthdayYear.Year%12;
switch(i)
{
case 4:
return "鼠";
break;
case 5:
return "牛";
break;
case 6:
return "虎";
break;
case 7:
return"兔";
break;
case 8:
return"龙";
break;
case 9:
return"蛇";
break;
case 10:
return"马";
break;
case 11:
return"11";
break;
case 0:
return"猴";
break;
case 1:
return"鸡";
break;
case 2:
return"狗";
break;
case 3:
return"猪";
break;
}
return "";
}