#region using diretives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregionnamespace 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();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregionnamespace 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();
}
}
}
Time t=new Time(currentTime);第一行是currenTime
第二行是currentTime不一样哦,呵呵
这个方法也是这样的错误哦
错误 1 程序“D:\文档\hello\hello\obj\Debug\hello.exe”不包含适合于入口点的静态“Main”方法 ahello
错误 1 程序“D:\文档\hello\hello\obj\Debug\hello.exe”不包含适合于入口点的静态“Main”方法 ahello
public class tester
{
static void main()
{
System.DateTime currenTime=System.DateTime.Now;
Time t=new Time(currentTime);
t.DisplayCurrentTime();
}
}放在命名空间下
{
public class tester
{
static void main()
{
System.DateTime currentTime = System.DateTime.Now;
Time t = new Time(currentTime);
t.DisplayCurrentTime();
}
}
public class Time
{
int Year;
int Month;
int Date;
int Hour;
int Minute;
#region using diretives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregionnamespace 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(currenTime);
t.DisplayCurrenTime();
}
}
}