delegate variables

In this chapter you will learn:

  1. Casting delegate variables

Casting delegate variables

Two delegate variables aren't equal.

using System;/*from j  a  v  a 2s .c o  m*/
delegate void Printer();
delegate void Display();

class Test
{
    static void consolePrinter()
    {
        Console.WriteLine("hi");
    }
    static void Main()
    {
        Printer p = consolePrinter;

        Display d = p;

    }
}

Compile time error.

Next chapter...

What you will learn in the next chapter:

  1. Polymorphic parameters for delegate
  2. Delegate with reference paramemters
Home » C# Tutorial » delegate, lambda, event
delegate
Multicast delegate
delegate variables
delegate parameters
Generic delegate
delegate return
Func and Action
delegate new
chained delegate
Anonymous delegate
delegate array
Return a delegate
delegate as parameter
Event
event multicast
static event
EventHandler
Event pattern
lambda
lambda syntax
Func, Action and lambda
lambda with outer function
lambda iteration variables