Robby
Mon Dec 13 05:54:23 CST 2004
Hi Ken
Tom gave me a link that answers this new question about non-collection
generic classes. It seems I will not have to repeat the "(Of MyType)" in
the class method definitions.
Thanks again.
Robby
"Robby" <edmund@not.my.email.com> wrote in message
news:%23I3PtgQ4EHA.3380@TK2MSFTNGP09.phx.gbl...
>
> Thanks Ken. I also found this article about generic collections.
>
>
http://msdn.microsoft.com/msdnmag/issues/04/09/AdvancedBasics/default.aspx
>
> In this article they say that you will be able to use generics on methods
> with the following syntax;
>
> Public Sub Swap(Of MyType) (ByRef item1 As MyType, _
> ByRef item2 As MyType)
> Dim temp As MyType
> temp = item1
> item1 = item2
> item2 = temp
> End Sub
>
> Do you know if this will be able to be done on class definitions so that
> generic classes that are not collections can be created. For example,
> will the following be valid in VB.Net 2005?
>
> Public Class MyGenericClass(Of MyType)
>
> Private data1 As MyType
>
> Public Sub New(Of MyType) (newData as MyType)
> data1 = newData
> End Sub
>
> Public Sub DoStuff(Of MyType) (data As MyType, repeat As Long)
> 'Do stuff
> End Sub
>
> End Class
>
> Thanks again.
>
> Robby.
>
>
>
> "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> news:uUe77TQ4EHA.2572@tk2msftngp13.phx.gbl...
>> Hi,
>>
>> In vb.net 2005 they will be supported.
>>
http://msdn2.microsoft.com/library/x6z0kw1a.aspx
>>
>> Ken
>> ------------------
>> "Robby" <edmund@not.my.email.com> wrote in message
>> news:e9UioNQ4EHA.2288@TK2MSFTNGP11.phx.gbl...
>>
>> In C++ I can write template classes and in C# they have generic classes
>> that
>> are something like C++ template classes. Is there currently a why to
>> write
>> them in VB? MS is adding C++ type functionality like operator
>> overloading
>> to VB in version 2.0 of the .Net Framework. Will there be a way in
>> version
>> 2.0 to write generic classes in VB?
>>
>> If not does anyone know the syntax to create an instance of a C# generic
>> class in VB?
>>
>> Thanks
>>
>> Robby
>>
>>
>>
>
>