Delegate SingleCast

SingleCast Delegate

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Memory_understanding
{

//    ---------------understanding Delegates /Multicast/SingleCast/Generic ---------------///
//    singlecast delegate

    class singlecasedelegate
    {
        delegate string function1(string display);
        static function1 fun = displaymyfunction;

        static string displaymyfunction(string display)
        {
            return display+" this is single delegate";
        }

        public static void Main()
        {

            //invokation of single delegate
            string t=fun.Invoke("Hello");
            Console.WriteLine(t);

            //2nd way of invocation
            function1 fun1 = new function1(displaymyfunction);
            string t1 = fun1("Hello ");
            Console.WriteLine(t1);
            Console.ReadLine();
        }



    }

Comments

Popular posts from this blog

Authentication and Authorization in Web API -Part1

My Gardening Journey 6