//为操作方便,我封闭了一个类,代码如下:

class The_Day
        {
             public static string getTheDay()
             {
                 string strDay = "";
                 string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
                 System.DateTime currentTime = System.DateTime.Now;
                 strDay = currentTime.Year +
                          "年" + currentTime.Month+
                          "月" + currentTime.Day+
                          "日" + currentTime.Hour+
                          "时" + currentTime.Minute+
                          "分" + currentTime.Second+
                          "秒 "+Day[(int)System.DateTime.Now.DayOfWeek];
                 return (strDay);           
             }
        }

//调用代码如下:
Console.WriteLine(The_Day.getTheDay()+" By yxHuang!...");






本文转载:CSDN博客