[C#] Delegate3

c# 2023. 1. 14. 22:50
728x90
public partial class Program
{
    private delegate int AreaCalculatorDelegate(int x, int y);
    static void Main(string[] args)
    {
        AreaCalculatorDelegate rect = Rectangle;
        AreaCalculatorDelegate sqr = Square;
        int i = rect(1, 2);
        int j = sqr(2, 3);
        Console.WriteLine($"{i}, {j}");
    }

}

public partial class Program
{
    static int Rectangle(int a, int b)
    {
        return a * b;
    }


    static int Square(int x, int y)
    {
        return x * y;
    }

}
728x90

'c#' 카테고리의 다른 글

[C#] Delegate 제네릭  (0) 2023.01.15
[C#] Delegate 멀티캐스트  (0) 2023.01.14
[C#] Delegate2  (0) 2023.01.14
[C#] 메서드 체인  (0) 2023.01.13
[C#] 커링  (0) 2023.01.13
Posted by 바르마스
,