gpt4 book ai didi

events - 有没有办法在单个 [] block 中包含多个事件声明?

转载 作者:行者123 更新时间:2023-12-01 15:40:50 26 4
gpt4 key购买 nike

写起来有点乏味:

let e1 = Event<_>()
let e... = Event<_>()
let en = Event<_>()

[<CLIEvent>]
member this.E1 = e1.Publish
[<CLIEvent>]
member this.E... = e....Publish
[<CLIEvent>]
member this.En = en.Publish

在代码中,我展示了我需要如何编写 n [<CLIEvent>] , 每个事件 1 个。

最佳答案

[<CLIEvent>]不是“ block ”,而是属性

一个属性在它之后立即应用于成员,所以不,你不能有相同的 [<CLIEvent>]应用于多个成员的属性。

但是如果有帮助,您可以将它们放在同一行:

[<CLIEvent>] member this.E1 = e1.Publish
[<CLIEvent>] member this.E... = e....Publish
[<CLIEvent>] member this.En = en.Publish

关于events - 有没有办法在单个 [<CLIEvent>] block 中包含多个事件声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30462637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com