Ejemplo n.º 1
0
    static void Main(string[] args)
    {
        // Generic Action
        Action<string, ConsoleColor, int> actionTarget =
            new Action<string, ConsoleColor, int>(ActionFuncDel.DisplayMessage);
        actionTarget("yo action", ConsoleColor.Yellow, 5);

        Func<int, int, int> funcTarget1 =
            new Func<int, int, int>(ActionFuncDel.Add);
        int ret = funcTarget1(70, 80);
        Console.WriteLine("Func<int,int,int> ret = {0}", ret);

        Func<int, int, string> funcTarget2 =
            new Func<int, int, string>(ActionFuncDel.SumToString);
        string strRet = funcTarget2(90, 300);
        Console.WriteLine("Func<int,int,string> ret = {0}", strRet);

        // Generic Delegate demo
        GenDel.TestGenDelegate();

        TestCar();

        TestMath();

        TestDelegate1 td1 = new TestDelegate1();
        td1.TestNumberChanger();
        TestDelegate2 td2 = new TestDelegate2();
        int[] iArray = {3,5,1,3,8};

        td2.TestCompareInt(TestDelegate2.SortType.Ascending, iArray);
        td2.TestCompareInt(TestDelegate2.SortType.Descending, iArray);
    }