Home All Groups Group Topic Archive Search About

TItem, TData, etc? Generics

Author
9 Nov 2006 10:46 PM
Spam Catcher
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.

Author
9 Nov 2006 11:40 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Spam Catcher" <spamhoneypot@rogers.com> schrieb:
> 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)'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
10 Nov 2006 12:36 AM
Spam Catcher
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in
news:Om9NxhFBHHA.204@TK2MSFTNGP04.phx.gbl:

> 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 :)
Author
12 Nov 2006 5:27 PM
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))


--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"Spam Catcher" <spamhoneypot@rogers.com> wrote in message
news:Xns9876B4BCEE98Dusenethoneypotrogers@127.0.0.1...
> 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.