Example #1
0
        static void Main(string[] args)
        {
            //Individually calling or indicate
            arithmatic calc = Add;

            calc(10, 5);
            calc = Sub;
            calc(10, 5);

            Person p = new Person();

            calc = p.AddtoCgpa;
            calc(70, 80);

            //at a time calling and added all method/ multi-custing
            arithmatic calc2 = Add;

            calc2 += Sub;
            calc2 += p.AddtoCgpa;

            calc2(30, 20);

            //remove one method

            calc2 -= Sub;
            calc2(70, 60);
        }
Example #2
0
        public ActionResult Index(arithmatic p, string operation)
        {
            if (operation == "add")
            {
                p.res = p.a + p.b;
            }
            else if (operation == "sub")
            {
                p.res = p.a - p.b;
            }


            return(View(p));
        }
Example #3
0
        static void Main(string[] args)
        {
            arithmatic calc = Add;

            calc(12, 14);
            calc = Sub;
            calc(13, 1);
            Person p = new Person();

            calc = p.AddtoCgpa;
            calc(90, 80);

            arithmatic calc2 = Add;

            calc2 += Sub;
            calc2 += p.AddtoCgpa;
            calc2(78, 70);

            calc2 -= p.AddtoCgpa;
            calc2(78, 70);
        }