copyOfDelegate가 원본 대표 복사본 대신 원본 대리자 복사본 인 이유는 무엇입니까?.net 대리자 지정 연산자가 원래 대리자에 대한 참조를 할당하지 않는 이유는 무엇입니까?
public class DelegateTester
{
public delegate void PrintDelegate();
public PrintDelegate PrintCallback;
}
public class Client
{
public void Print()
{
Console.WriteLine("in client");
}
}
static void main()
{
DelegateTester tester = new DelegateTester();
Client client = new Client();
tester.PrintCallback += new DelegateTester.PrintDelegate(client.Print);
tester.PrintCallback += new DelegateTester.PrintDelegate(client.Print);
// copy the delegate
DelegateTester.PrintDelegate copyOfDelegate = tester.PrintCallback;
tester.PrintCallback -= new DelegateTester.PrintDelegate(client.Print);
tester.PrintCallback();
copyOfDelegate.Invoke();
}