Without parameters

suggest change

This example shows how to create a delegate that encapsulates the method that returns the current time

static DateTime UTCNow()
{
    return DateTime.UtcNow;
}

static DateTime LocalNow()
{
    return DateTime.Now;
}

static void Main(string[] args)
{
    Func<DateTime> method = UTCNow;
    // method points to the UTCNow method
    // that retuns current UTC time  
    DateTime utcNow = method();

    method = LocalNow;
    // now method points to the LocalNow method
    // that returns local time

    DateTime localNow = method();
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents