如何使用C#自定义一个时间类,该类包含时,分,秒字段与属性?

C#自定义一个时间类,该类包含时,分,秒字段与属性,具有将时间增加1秒,1分,1小时的方法,具有分别显示时,分,秒同时显示时分秒的方法

料青山看我应如是
浏览 393回答 2
2回答

不负相思意

class MyDate{int hour;public int Hour{get { return hour; }set { hour = value; }}int min;public int Min{get { return min; }set { min = value; }}int sec;public int Sec{get { return sec; }set { sec = value; }}public DateTime AddSecond(){return DateTime.Now.AddSeconds(1);}public DateTime AddMin(){return DateTime.Now.AddMinutes(1);}public DateTime AddHour(){return DateTime.Now.AddHours(1);}public string ShowSecond(){return DateTime.Now.Second.ToString();}public string ShowMin(){return DateTime.Now.Minute.ToString();}public string ShowHour(){return DateTime.Now.Hour.ToString();}public string ShowAll(){return DateTime.Now.Hour.ToString() +":"+ DateTime.Now.Minute.ToString() +":"+ DateTime.Now.Second.ToString();}}
打开App,查看更多内容
随时随地看视频慕课网APP