开发者

Is there anything readily available in the .NET framework of the form EventArgs<T>? [duplicate]

开发者 https://www.devze.com 2023-01-11 19:18 出处:网络
This question already has answers here: Does .NET have a built-in EventArgs<T>? (7 answers) Closed 9 years ago.
This question already has answers here: Does .NET have a built-in EventArgs<T>? (7 answers) Closed 9 years ago.

Is there something like this already availab开发者_如何学JAVAle in the .NET framework?

public class EventArgs<T> : EventArgs {
    private readonly T data;

    public EventArgs(T data) {
        this.data = data;
    }
}

I know there is a generic event handler, I'm kinda surprised I can't find a generic EventArgs class.

Thanks


No. Mainly because it fails the tests posed before something it added to the framework

  • How useful is it? (Marginly -- only useful if you only need one data member. As opposed to EventHandler<> which is good for event handler regardless of the number of parameters used.)
  • How hard is it to write yourself? (not very hard)
  • Is it needed in the framework itself? (No. Distinct classes are used, so new members could be added in the future if needed. As opposed to Func<> & Action<> which are used by the framework.)

(UPDATED based on comments)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号