A delegate is not an instance - it is a variable holding a reference to a method.
As a result, you cannot instantiate it by using the
new
operator: that would imply that you are creating a new method, which is plainly silly!
If you think of a delegate as a "Pointer to a method" then you are there. It is a way to access a method later without needing to know it's name at that point.
public string GetScreenName() { return "Screen"; }
public string GetPrinterName() { return "Printer"; }
public delegate string GetNameMethod();
public GetNameMethod GetName;
...
if (isUsingScreen)
{
GetName = GetScreenName;
}
else
{
GetName = GetPrinterName;
}
Console.WriteLine(GetName());