我目前在我的新项目中使用f#和XNA,但是在实现XNA的IUpdateable接口时卡住了。特别是当我需要实现事件处理程序时。
这是我的:
let enabledChanged = new DelegateEvent<System.EventHandler>()
及以下:
interface IUpdateable with
... // other stuff
[<CLIEvent>]
member self.EnabledChanged = enabledChanged.Publish
但是我得到这个错误:
Error 2 This expression was expected to have type EventHandler but here has type EventHandler<EventArgs>
我已经尝试了几件事,但不能得到这个工作。预计会有什么?
提前感谢!
您是否尝试过以以下方式定义enabledChanged
?
let enabledChanged = new Event<_>()
我看到IUpdatable。EnabledChanged的类型是system . eventandler
type X() =
let enabledChanged = DelegateEvent<EventHandler<_>>()
interface IUpdateable with
[<CLIEvent>]
member this.EnabledChanged = enabledChanged.Publish
type Y() =
let enabledChanged = Event<EventHandler<_>, _>()
interface IUpdateable with
[<CLIEvent>]
member this.EnabledChanged = enabledChanged.Publish