Search code examples
c#.netgenericseventsfcl

Generic built-in EventArgs to hold only one property?


I have a number of EventArgs classes with only one field and an appropriate property to read it:

public class SomeEventArgs : EventArgs
{
    private readonly Foo f;
    public SomeEventArgs(Foo f)
    {
        this.f = f;
    }
    public Foo Foo
    {
        get { return this.f; }
    }    
}

Is there any built-in, generic class to implement such behavior or I have to roll my own?

public class GenericEventArgs<T> : EventArgs
{
    private readonly T value;
    public GenericEventArgs(T v)
    {
        this.value = v;
    }
    public T Value
    {
        get { return this.value; }
    }    
}

P.S. I wrote a suggestion on Microsoft Connect


Solution

  • I do not think there is.
    Looks like you are not the only one to ask himself this question.
    Take a look here