I have tried to write:
Event EventName(Of T)()
But Visual Studio tells me that "Type parameters cannot be specified on this declaration."
Is such a declaration possible or will I have to put T as a regular argument?
I have tried to write:
Event EventName(Of T)()
But Visual Studio tells me that "Type parameters cannot be specified on this declaration."
Is such a declaration possible or will I have to put T as a regular argument?
The Event keyword is similar to declaring a field within your class. You wouldn't expect to find:
Private i as GenericClass(Of T)
inside a class that isn't already generic.
You can declare a Delegate with a generic type:
Public Delegate Sub Blah(Of T)()
But then you'd declare your event to be of a concrete type:
Public Event EventName As Blah(Of Int16)
Or if your class was generic, you'd then be able to declare the event as generic too:
Public Delegate Sub Blah(Of T)()
Public Class Referral(Of U)
Public Event EventName As Blah(Of U)
End Class
Of course, all of these empty argument lists look rather suspect also. We may do better if you can provide more code/more explanation of what you're trying to do.