using System.Xml;
namespace CSharp1
{
internal class Program
{
delegate int OnClicked();
//delegete ->형식은 형식인데, 함수 자체를 인자로 넘겨주는 그런 형식
//반확:int 입력:void
//OnClicked 이 delegate 형식의 이름이다!
//UI
static void ButtonPressed(OnClicked clickedFunction)
{
clickedFunction();
}
static int TestDelegate()
{
Console.WriteLine("Hello Delegate");
return 0;
}
static int TestDelegate2()
{
Console.WriteLine("Hello Delegate 2");
return 0;
}
static void Main(string[] args)
{
//delegate(대리자)
Console.WriteLine();
OnClicked clicked = new OnClicked(TestDelegate);
clicked += TestDelegate2;
ButtonPressed(clicked);
}
}
}
'C#' 카테고리의 다른 글
Lambda(람다식) (0) | 2023.07.12 |
---|---|
Event(이벤트) (0) | 2023.07.12 |
Property(프로퍼티) (0) | 2023.07.10 |
Interface (0) | 2023.07.10 |
Generic (0) | 2023.07.10 |