[英]how do I fix this error, "There is no arguments given that corresponds to the required formal parameter"?
[英]How do i pass in the arguments for DateTime so it corresponds to the required formal Parameter in C#
如何為 DateTime 傳遞 arguments 以便它對應於所需的形式參數? 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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.