Func<TResult>() 대리자 :: iopeni - Think of C#

 

입력 파라미터가 없는 Func대리자의 사용법이다..

Func<string> myDel = Hello;

if (myDel != null) Console.WriteLine(myDel());

static string Hello()

{

string strHello = "안녕하세요?";

return strHello;

}

 

만약 입력 파라미터가 있다면 다음과 같이 할 수 있습니다.

 

Func<T, TResult> 대리자

public delegate TRsult Func<in T1, .... , out TResult>(T1 arg1,....)

 

입니다.

 

Func<string, int, string> myDel = invitedMember;

if (myDel != null) myDel("동이", 3);

 

static string infitedMember(string name, int grade)

{

return name;

}

 

 

'Functional World > C#' 카테고리의 다른 글

boxing 에 대한 생각의 오류....  (0) 2013.09.30
IEnumerator 사용하기 - 기초  (0) 2013.08.11
Generic Collections  (0) 2013.07.15
C# 5.0 async, await  (0) 2013.07.05
Runtime에 클래스 맴버를 취득 하고자 할 경우….  (0) 2013.07.04
Posted by 프로그래머란 카페인을 코드로 변환하는 기계다
,