当我从课堂上发现这个时,我正在使用 ILSpy 仔细阅读一些系统System.Internal.HandleCollector
类:
internal sealed class HandleCollector
{
... bunch of stuff removed ...
internal static event HandleChangeEventHandler HandleAdded
{
[MethodImpl(MethodImplOptions.Synchronized)]
add
{
HandleCollector.HandleAdded = (HandleChangeEventHandler)Delegate.Combine(HandleCollector.HandleAdded, value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove
{
HandleCollector.HandleAdded = (HandleChangeEventHandler)Delegate.Remove(HandleCollector.HandleAdded, value);
}
}
... bunch of stuff removed ...
}
当 VisualStudio 抱怨(我复制了该类)该属性没有设置器时,微软如何编译它?有人可以分解为什么这有效但我的 VS 副本抱怨(构建标志?)?
此属性没有设置器
每个HandleCollector.HandleAdded =
语句都有错误。