보기보다 해협 앞으로 비 동적 포인트 :
죄송 없습니다하지만 -하지만 객체의 유형이있다 그 수 예를 들어 델리게이트 (delegate)라고 불린다.
Func<int, int> myDelagate = x=>x*2;
int four = myDelagate(2)
가 비록 기본 속성입니다 - 적어도 하나 개의 매개 변수를 가지고 있어야하고 액세스 배열 액세스 다음과 같습니다
class Test1
{
public int this[int i, int j]
{
get { return i * j; }
}
}
그런 다음 당신이 할 수있는
Test1 test1 = new Test1();
int six = test1[2, 3];
를 호출 위와 같은 대표와 함께 정말 바보 같은 것들 :
class Test2 // I am not saying that this is a good idea.
{
private int MyFunc(int z, int i)
{
return z * i;
}
public Func<int, int> this[int i] { get { return x => MyFunc(x, i); } }
}
그런 다음 이런 이상하게 보인다 호출 :
Test2 test = new Test2();
test[2](2); // this is quite silly - don't use this.....
+1 굉장 질문이 있습니다. – ClosureCowboy