Polymorphic parameters for delegate

delegate can accept more specific parameters.


using System;
delegate void Printer(object t);

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

        object obj = "java2s.com";
        p(obj);
    }
}

The output:


java2s.com
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.