Home All Groups Group Topic Archive Search About

Generics (input - output) either dataset or typed dataset

Author
15 Mar 2006 12:05 AM
Karl 140.6
Generics are new to me.

I want to write a function that accepts a generic parameter that is either a
dataset or a typed dataset.  Have the function fill that object and return it.

Is this possilbe without casting it as an object and then ctype the returned
object to the desired type.

I thought generics will allow me to pass a dataset and have it filled or
pass a typed dataset and have it filled, using the same function.

Thank you for your help,

Karl

Author
15 Mar 2006 5:08 PM
Claes Bergefall
I haven't really done much with generics, but something like this should
work:

Public Function FillDataSet(Of T As DataSet)(ByVal ds As T) As T
End Function

   /claes

Show quoteHide quote
"Karl 140.6" <Karl1***@discussions.microsoft.com> wrote in message
news:AFABAE66-DAC9-4F77-A3EE-42305F9A0373@microsoft.com...
> Generics are new to me.
>
> I want to write a function that accepts a generic parameter that is either
> a
> dataset or a typed dataset.  Have the function fill that object and return
> it.
>
> Is this possilbe without casting it as an object and then ctype the
> returned
> object to the desired type.
>
> I thought generics will allow me to pass a dataset and have it filled or
> pass a typed dataset and have it filled, using the same function.
>
> Thank you for your help,
>
> Karl