这段代码运行的时候出错了,一直不知道问题出在哪,望高手指点!
#region using diretives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion
namespace DeclaringConstructor
{
public class Time
{
int Year;
int Month;
int Date;
int Hour;
int Minute;
int Second;
public void DisplayCurrenTime()
{
System.Console.WriteLine("{0}/{1}/{2} {3}:{4}:{5}",Month,Date,Year,Hour,Minute,Second);
}
public Time(System.DateTime dt)
{
Year=dt.Year;
Month=dt.Month;
Date=dt.Day;
Hour=dt.Hour;
Minute=dt.Minute;
Second=dt.Second;
}
}
public class tester
{
static void main()
{
System.DateTime currenTime=System.DateTime.Now;
Time t=new Time(currentTime);
t.DisplayCurrentTime();
}
}
}
[解决办法]
System.DateTime currenTime=System.DateTime.Now;
Time t=new Time(currentTime);
第一行是currenTime
第二行是currentTime
不一样哦,呵呵
[解决办法]