﻿namespace DelegatesExample
{
    using System;

    // Declaration of delegate
    public delegate void SimpleDelegate(string param);

    public class Startup
    {
        public static void Main(string[] args)
        {
            // Instantiate the delegate
            var d = new SimpleDelegate(TestMethod);

            // The above can be written in a shorter way
            d = TestMethod;

            // Invocation of the method, pointed by delegate
            d("test");
        }

        private static void TestMethod(string param)
        {
            Console.WriteLine("I was called by a delegate.");
            Console.WriteLine($"I got parameter {param}.");
        }
    }
}
