SoFunction
Updated on 2025-03-07

Small example of C# delegate


static void Main(string[] args)
        {
           (Exec(GetSet));
           ();
        }
//Define a delegate to pass the method as a parameter to Exec.
        public delegate string GetResultDelegate();
        public static string Get()
        {
            return "get";
        }

        public static string GetTest()
        {
            return "gettest";
        }

        public static string GetSet()
        {
            return "getSet";
        }


        public static string Exec(GetResultDelegate getResult)
        {
            return getResult();
 }