第一步:首先引入命名空间
using System.Globalization;
第二步:编写获取方法
public string GetChineseZodiac(DateTime time)
{
ChineseLunisolarCalendar chineseLunisolarCalendar = new ChineseLunisolarCalendar();
int year = chineseLunisolarCalendar.GetSexagenaryYear(time);
string treeYear = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
string chineseZodiac = treeYear.Substring(chineseLunisolarCalendar.GetTerrestrialBranch(year) - 1, 1);
return chineseZodiac;
}