I'm surprised how many people don't realize that we (and by we I mean VB) have full generic support in Whidbey. We can consume, author, and use constraints. I just answered an internal email where someone was wondering how this all worked and I figured this
info would be useful to all you Channel9 types.
Variables Imports System.Collections.Generic
Dim foo as New List(Of String) Dim bar as New Dictionary(Of String, String)
Functions Module Test
Public Sub Foo(Of T)(ByVal param As T) End Sub
Public Sub Bar() Dim x as String ' call explictly the one you want Foo(Of String)(x) ' or let the compiler do it for you Foo(x) ' same as above End Sub
Classes Public Class Foo(Of G,E,N,E,R,I,C,S) End Class
Public Class Foo(Of T As IEnumerable) End Class
Happy Coding (especially if it's in VB )
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.