델리게이트
개발 Programming/C#2015. 4. 24. 13:54
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
delegate int MyDelegate(int a, int b);
class CalCulator
{
public int Plus(int a, int b)
{
return a + b;
}
public static int Minus(int a, int b)
{
return a - b;
}
}
class MainApp
{
static void Main(string[] args)
{
CalCulator Calc = new CalCulator();
MyDelegate CallBack;
CallBack = new MyDelegate(Calc.Plus);
Console.WriteLine(CallBack(3,4));
CallBack = new MyDelegate(CalCulator.Minus);
Console.WriteLine(CallBack(7,5));
}
}
}
소스를 참조로 전달해서 사용하기 위함
'개발 Programming > C#' 카테고리의 다른 글
일반화 프로그래밍- 일반화 클래스 (0) | 2015.04.24 |
---|---|
일반화 프로그래밍-일반화 메소드 (0) | 2015.04.24 |
인덱서 : 객체 배열화 (0) | 2015.04.23 |
프로퍼티 무명 형식 프로퍼티 (0) | 2015.04.23 |
프로퍼티를 이용한 객체 초기화 (0) | 2015.04.23 |
댓글()