Essential C# Func delegates  Suggest an edit

Without parameters

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();

Table Of Contents
22 Enum
107 Stream
108 Timers
121 Func delegates
  ↑ ↓ to navigate     ↵ to select     Esc to close