Does .NET have a built-in EventArgs?

前端 未结 7 1205
梦如初夏
梦如初夏 2020-11-30 06:34

I am getting ready to create a generic EventArgs class for event args that carry a single argument:

public class EventArg : EventArgs
{
    // Prope         


        
相关标签:
7条回答
  • 2020-11-30 07:07

    No. You probably were thinking of EventHandler<T>, which allows you to define the delegate for any specific type of EventArgs.

    I personally don't feel that EventArgs<T> is quite as good of a fit, though. The information used as a "payload" in the event args should be, in my opinion, a custom class to make it's usage and expected properties very clear. Using a generic class will prevent you from being able to put meaningful names into place. (What does "Data" represent?)

    0 讨论(0)
提交回复
热议问题