2009年11月18日 星期三

C# 今天星期幾

           string timeweek = "";
string timekey = DateTime.Parse(newtime.Substring(0, 4) + "/" + newtime.Substring(4, 2) + "/" + newtime.Substring(6, 2)).DayOfWeek.ToString();
if (timekey == "Sunday")
{
timeweek = "星期日";
}
else if (timekey == "Monday")
{
timeweek = "星期一";
}
else if (timekey == "Tuesday")
{
timeweek = "星期二";
}
else if (timekey == "Wednesday")
{
timeweek = "星期三";
}
else if (timekey == "Thursday")
{
timeweek = "星期四";
}
else if (timekey == "Friday")
{
timeweek = "星期五";
}
else if (timekey == "Saturday")
{
timeweek = "星期六";
}

沒有留言:

張貼留言