Functional World/C#
Func<TResult>() 대리자
프로그래머란 카페인을 코드로 변환하는 기계다
2013. 7. 4. 10:51
입력 파라미터가 없는 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;
}