using System;
static class Program
{
static event Action A = delegate { };
static event Action B = delegate { };
static void Main()
{
A += B;
B += ()=>Console.WriteLine("yeah");
A.Invoke();
}
}
这不会打印任何内容,但是如果我交换 Main 的前两行,它会打印。
最佳答案
事件是不可变的,即在分配时您会得到一个副本,例如整数
int a = 1;
int b = 2;
a += b; // a == 3
b += 1; // a is still 3
关于.net - 在 .NET 中,为什么事件连接顺序如此重要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7738871/