/// <summary>
        /// Main Method
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ClsDelegateDemo4 obj = new ClsDelegateDemo4();
            Func <int, double, float, double> obj1 = new Func <int, double, float, double>(obj.Add);

            obj1.Invoke(34, 29.4, 9.5f);

            Action <double, float> obj2 = new Action <double, float>(obj.Addition);

            obj2(8.5, 3.2f);

            Predicate <string> obj3 = new Predicate <string>(obj.Test);
            // (or) //Func<string, bool> obj3 = new Func<string, bool>(obj.Test);
            bool status = obj3.Invoke("dotnet language");

            log.Info(status);
            Console.ReadLine();
        }
Beispiel #2
0
        /// <summary>
        /// I the Main method creating generic delegate with Lambda expression
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ClsDelegateDemo4 obj = new ClsDelegateDemo4();
            Func <int, double, float, double> obj1 = (a, b, c) =>
            {
                double d = a + b + c;
                return(d);
            };
            double result = obj1.Invoke(34, 29.4, 9.5f);

            log.Info("The addition of a,b and c is:" + result);

            Action <double, float> obj2 = (a, b) =>
            {
                double c = a + b;
                log.Info("The addition of a and b is:" + c);
            };

            obj2(8.5, 3.2f);

            Predicate <string> obj3 = (str) =>
            {
                if (str.Length > 7)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            bool status = obj3.Invoke("dotnet language");

            log.Info(status);
            Console.ReadLine();
        }