代表相等

在委託上呼叫 .Equals() 比較引用相等:

Action action1 = () => Console.WriteLine("Hello delegates");
Action action2 = () => Console.WriteLine("Hello delegates");
Action action1Again = action1;

Console.WriteLine(action1.Equals(action1)) // True
Console.WriteLine(action1.Equals(action2)) // False
Console.WriteLine(action1Again.Equals(action1)) // True

在多播委託上執行+=-= 時,這些規則也適用,例如訂閱和取消訂閱事件時。