访问定制eventargs类中的值 [英] access values within custom eventargs class
问题描述
我总是需要使用委托/事件处理程序来获取存储在自定义EventArgs类中的数据, / div>
定制 EventArgs
类就像任何其他类一样。如果你有一个实例,你可以访问它的(可见)成员。
然而,通常情况下, EventArgs
仅与事件结合使用,您需要一个委托来订阅一个事件。因此,通常可以使用某些形式的委托(来自消费端),尽管这可以是引用标准方法的委托,您可以使用 EventArgs
子类。
Do I always need to use a delegate / Eventhandler to get to the data stored within a custom EventArgs class or can I access it directly?
A custom EventArgs
class is just like any other class. If you have an instance of it, you can access it's (visible) members.
Typically, however, EventArgs
is only used in conjunction with events, and you need a delegate to subscribe to an event. As such, it would normally be used (from the consumption side) with some form of delegate, though this could just be a delegate referencing a standard method where you use the EventArgs
subclass.
这篇关于访问定制eventargs类中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!