我如何传递DateTime的参数,使其与所需的形式参数相对应?Int, string和double都没有问题,但是这让我很头疼。
class Activity
{
public int Id { get; set; }
public int MinAge { get; set; }
public int MaxAge { get; set; }
public static DateTime StartTime { get; private set; }
public static DateTime EndTime { get; private set; }
public Activity(int id, int minAge, int maxAge, DateTime startTime, DateTime endTime)
{
Id = id;
MinAge = minAge;
MaxAge = maxAge;
StartTime = startTime;
EndTime = endTime;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Activity ak1 = new Activity(1, 15, 21, ?, ?);
}
}
需要发送类型为DateTime
的参数。所以你可以发送DateTime.Now
或者如果你有日期那么就像这样重载构造函数new DateTime(2008, 5, 1, 8, 30, 52)