TItem, TData, etc? Generics

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.
 
H

Herfried K. Wagner [MVP]

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)'.
 
G

Guest

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 :)
 
J

Jay B. Harlow

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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top