NewProgrammer123
NewProgrammer123

Reputation: 31

How do i pass in the arguments for DateTime so it corresponds to the required formal Parameter in C#

How do I pass in the arguments for DateTime so it corresponds to the required formal parameter? Int, string and double are NO problem, but this is giving me true headache.

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, ?, ?); 
    }
}

Upvotes: 2

Views: 307

Answers (1)

StepUp
StepUp

Reputation: 38134

It is necessary to send parameter of type DateTime. So you can send DateTime.Now or if you have date, then just use overloading of constructor like this new DateTime(2008, 5, 1, 8, 30, 52)

Upvotes: 2

Related Questions