我有一个用户控制,处理文件上传。我已经定义了一个委托如下:
公共委托无效FileUploadSuccess< T>(吨价,FileUploadType F)
值可以是一个字符串和字节数组。 FileUploadType是一个枚举告诉这类型的文件被上传。
现在我已经宣布在用户控件一个事件,以提高这一点。
公共事件FileUploadSuccess<字符串> successString; //如果我想要一个文件名
公共事件FileUploadSuccess<字节[]> successStringImage; //如果我想要一个byte [上传图像]
我想要的是一个普通的事件
公共事件FileUploadSuccess< T> successString。
解决方案
除非泛型类型的一部分(即
类Foo< T> {公共事件SomeEventType< T> SomeEventName; }
)有没有这样的东西作为通用属性,字段,事件,索引或经营者(只有泛型类型和泛型方法)。可以包含类型在这里是通用的?
I have a user control which deals with fileupload. I have defined a delegate as follows
public delegate void FileUploadSuccess<T>(T value,FileUploadType F)
value can be a string as well as byte array. FileUploadType is an enum which tells which type of file was uploaded.
Now i have declared a event in usercontrol to raise this.
public event FileUploadSuccess<string> successString; //In case i want a file name
public event FileUploadSuccess<Byte[]> successStringImage; // In case i want a byte[] of uploaded image
What i wanted was a generic event
public event FileUploadSuccess<T> successString.
解决方案
Except as part of generic types (i.e.
class Foo<T> { public event SomeEventType<T> SomeEventName; }
) there is no such thing as generic properties, fields, events, indexers or operators (only generic types and generic methods). Can the containing type here be generic?