로딩
요청 처리 중입니다...

C# Delegate, Func, Action, Invoke()

 C# Delegate, Func, Action, Invoke()

C# Delegate의 개념 C# Delegate는 C/C++의 함수 포인터와 비슷한 개념으로 메서드 파라미터와 리턴 타입에 대한 정의를 한 후, 동일한 파라미터와 리턴타입을 가진 메서드를 서로 호환해서 불러서 쓸수 있는 기능이다. 그래서 메서드를 변수처럼 저장하고 호출할 수 있다.

"델리게이트는 (참조형)타입이다." 타입(자료형) int,float과 같이 타입을 만드는것이다.

델리게이트 사용이유 콜백함수를 구현하는데 델리게이트를 사용한다. 콜백(CallBack) : 함수를 먼저 참조하고 나중에 호출한다 사용방법 1.

Delegate 선언 // Delegate 타입 정의 public delegate void MyDelegate(string message); // 선언한 Delegate변수 객체 선언 public MyDelegate _myDelegate; 2. Delegate 인스턴스 생성 및 사용 public class Program { public delegate void MyDe...