C#:Creating Multicast delegate with boolean return type

前端 未结 5 1702
执念已碎
执念已碎 2020-12-08 17:24

Hai Techies,

in C#, how can we define the multicast delegate which accepts a DateTime object and return a boolean.

Thanks

5条回答
  •  情深已故
    2020-12-08 17:37

    class Test
    {
        public delegate bool Sample(DateTime dt);
        static void Main()
        {
            Sample j = A;
            j += B;
            j(DateTime.Now);
    
        }
        static bool A(DateTime d)
        {
            Console.WriteLine(d);
            return true;
        }
        static bool B(DateTime d)
        {
            Console.WriteLine(d);
            return true;
        }
    }
    

提交回复
热议问题