Does .NET have a built-in EventArgs?

前端 未结 7 1244
梦如初夏
梦如初夏 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:06

    The reason this does not exist is because what would end up happening is you implement this, and then when you go to fill in the T you should create a class with strongly typed unambiguous properties that acts as the data bag for your event arg, but halfway through implementing that you realize there's no reason you don't just make that class inherit from EventArgs and call it good.

    Unless you just want a string or something similarly basic for your data bag, in which case there are probably EventArgs classes standard in .NET which are meant to serve whatever simple purpose you're getting at.

提交回复
热议问题