Creating and Consuming Generics
You can define the following types as generics: classes, interfaces, delegates, structures, and methods. Creating a generic type is accomplished by providing a parameterized type definition. The following is an example:
Class CustomType(Of T)End Class
The Of
keyword is followed by the type that the new object can handle. T
is the type parameter and represents the .NET type you want to be held by your generic type. The type parameter’s name is left to your own choosing, but T
is often used as a common name in the .NET Framework Base Class Library (BCL). At this point, you must write code to manipulate the T
type in a way that will be convenient for possibly every .NET type. Now imagine you want to build a custom ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.