TItem, TData, etc? Generics

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I declare an object to accept a TItem?

Also where is the documentation on TItem/TData/etc?


Here's the object:

Public Class DataEventArgs(Of TData)
Inherits EventArgs

Private innerData As TData

Here's the delgate which I want to pass a TItem

Public Delegate Sub EventListener(ByVal Sender As Object, ByVal e As
DataEventArgs(Of TItem)) <-- TItem doesn't work.
 
Spam Catcher said:
How do I declare an object to accept a TItem?

Also where is the documentation on TItem/TData/etc?


Here's the object:

Public Class DataEventArgs(Of TData)
Inherits EventArgs

Private innerData As TData

Here's the delgate which I want to pass a TItem

Public Delegate Sub EventListener(ByVal Sender As Object, ByVal e As
DataEventArgs(Of TItem)) <-- TItem doesn't work.

This does not work because 'TItem' does not seem to be a generic type
parameter of 'DataEventArgs(Of TData)'.
 
This does not work because 'TItem' does not seem to be a generic type
parameter of 'DataEventArgs(Of TData)'.

Hi,

I solved the issue - I had the syntax wrong in using generics.

Thanks :)
 
Spam,
Public Delegate Sub EventListener(ByVal Sender As Object, ByVal e As
DataEventArgs(Of TItem)) <-- TItem doesn't work.
Depending on where you are trying to define EventListener you may need to
make the Delegate itself generic:

Public Delegate Sub EventListener(Of TItem)(ByVal sender As Object,
ByVal e As DataEventArgs(Of TItem))


Although I normally use EventHandler(Of T) then pass DataEventArgs(Of TItem)
as T.

Public Event Something As EventHandler(Of DataEventArgs(Of Whatever))
 
Back
Top