static void Main(string[] args) { // Delegate.Combine 을 이용하여 대리자 호출 목록 연결 PDelegate pd = (PDelegate)Delegate.Combine(new PDelegate(Plus), new PDelegate(Minus), new PDelegate(Div), new PDelegate(Mul)); pd(20, 10); }
static void Main(string[] args) { // 대리자에 Plus 함수 참조하여 대리자를 인스턴스화 PDelegate pd1 = Plus; // 무명함수를 참조하여 대리자를 인스턴스화 PDelegate pd2 = delegate(int a, int b) { return(a / b); }; Console.WriteLine("pd1의 값: " + pd1(10, 5)); Console.WriteLine("pd2의 값: " + pd2(10, 5)); }