delegate with generic type

delegate can have generic type.

 
using System;

delegate void Printer<T>(T t);

class Test
{
    static void consolePrinterInt(int i)
    {
        Console.WriteLine(i);
    }

    static void consolePrinterFloat(float f)
    {
        Console.WriteLine(f);
    }
    static void Main()
    {
        Printer<int> p = consolePrinterInt;

        p(2);

    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.