//方法1
private void btnQuery_DayOfWeek_Click(object sender, EventArgs e)
{
MessageBox.Show("今天是:"+"日一二三四五六".Substring((int)DateTime.Now.DayOfWeek,1);
}
private void btnQuery_DayOfWeek_Click(object sender, EventArgs e)
{
MessageBox.Show("今天是:"+"日一二三四五六".Substring((int)DateTime.Now.DayOfWeek,1);
}
//方法2
//必须添加 using System.Collections
private void btnQuery_DayOfWeek_Click(object sender, EventArgs e)
{
Hashtable htb = new Hashtable();
htb.Add("Monday","星期一");
htb.Add("Tuesday", "星期二");
htb.Add("Wednesday", "星期三");
htb.Add("Thursday", "星期四");
htb.Add("Friday", "星期五");
htb.Add("Saturday", "星期六");
htb.Add("Sunday", "星期日");
string str = htb[DateTime.Now.DayOfWeek.ToString().Trim()].ToString();
MessageBox.Show("今天是:" + str);
}
//必须添加 using System.Collections
private void btnQuery_DayOfWeek_Click(object sender, EventArgs e)
{
Hashtable htb = new Hashtable();
htb.Add("Monday","星期一");
htb.Add("Tuesday", "星期二");
htb.Add("Wednesday", "星期三");
htb.Add("Thursday", "星期四");
htb.Add("Friday", "星期五");
htb.Add("Saturday", "星期六");
htb.Add("Sunday", "星期日");
string str = htb[DateTime.Now.DayOfWeek.ToString().Trim()].ToString();
MessageBox.Show("今天是:" + str);
}