Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
442 B
2
Indexable
Never
using System;

class Program
{
    delegate void MyDelegate(int x);

    static void Main()
    {
        MyDelegate myDelegate = DisplayNumber;
        myDelegate(5);

        myDelegate += DoubleNumber;
        myDelegate(3);
    }

    static void DisplayNumber(int x)
    {
        Console.WriteLine($"The number is: {x}");
    }

    static void DoubleNumber(int x)
    {
        Console.WriteLine($"Double the number: {x * 2}");
    }
}
Leave a Comment