我有许多 EventArgs 类,它们只有一个字段和一个适当的属性来读取它:
public class SomeEventArgs : EventArgs
{
private readonly Foo f;
public SomeEventArgs(Foo f)
{
this.f = f;
}
public Foo Foo
{
get { return this.f; }
}
}
是否有任何内置的通用类来实现这种行为,或者我必须自己动手?
public class GenericEventArgs<T> : EventArgs
{
private readonly T value;
public GenericEventArgs(T v)
{
this.value = v;
}
public T Value
{
get { return this.value; }
}
}