我真的不明白这段代码有什么问题。它抛出了几个错误:
错误 CS0079:事件只能出现在or运算符
core.Events.Event.thisEvent
的左侧+=
-=
错误 CS0070:事件
core.Events.Event.thisEvent
只能出现在类型的左侧+=
或-=
在类型之外使用时core.Events.Event
错误 CS1502:匹配的最佳重载方法
System.Delegate.Combine(System.Delegate, System.Delegate)
有一些无效参数错误 CS1503:参数
#1
无法将object
表达式转换为类型System.Delegate
我做错了什么,我该如何解决?
using System;
using System.Runtime.CompilerServices;
namespace core.Events
{
public class Event
{
public delegate void EventDelegate (object from,EventArgs args);
public event Event.EventDelegate thisEvent {
[MethodImpl(MethodImplOptions.Synchronized)]
add {
this.thisEvent += (Event.EventDelegate)Delegate.Combine (this.thisEvent, value);
}
[MethodImpl(MethodImplOptions.Synchronized)]
remove {
this.thisEvent -= (Event.EventDelegate)Delegate.Remove (this.thisEvent, value);
}
}
public void call (object from, EventArgs args)
{
this.thisEvent (from, args);
}
}
}
预先感谢您的帮助,我想我只是超级累了,迷失在源头上...