delegate return type

The return type of a delegate can be more specific than the return type in delegate declaration.

For example, the delegate specifies that the return type is object, it may return a string type value.


using System;

delegate object Create();


class Test
{

    static string createString()
    {
        return "java2s.com";
    }

    static void Main()
    {
        Create c = createString;

        c();
    }
}
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.