C# TimeClass

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mytime
{
public class time
{
private
int Year;
int Month;
int Day;
int Hour;
int Minute;
int Second;
public
void Show()
{
Console.WriteLine("{0} {1} {2} {3} {4} {5}",Year, Month, Day, Hour, Minute,Second);
}
public time(System.DateTime dt){
Year = dt.Year;
Month = dt.Month;
Day = dt.Day;
Hour = dt.Hour;
Minute = dt.Minute;
Second = dt.Second;
}
public time( int Year = 0 , int Month = 0, int Date = 0, int Hour = 0, int Minute = 0,int Second = 0) { this.Year = Year; this.Month = Month; this.Day = Date; this.Hour = Hour; this.Minute = Minute;
}
}

class Tester
{
static void Main()
{
System.DateTime cT = System.DateTime.Now;
time t = new time(cT);
t.Show();
time t2 = new time(1995,3,21,8);
t2.Show();
}
}
}

posted @ 2015-03-23 22:40  燃烧灬  阅读(150)  评论(1编辑  收藏  举报