Implementing Generic Methods

In Listing 14.1 you saw how to implement a method that receives a generic type parameter. By the way, generic methods are something more. You can add the Of keyword to a generic method to parameterize the method, other than getting generic-type parameters. The following code provides an example, where two arrays of integers are swapped:

image

Continuing the executive code shown in the “Consuming Generic Types” section, the following snippet shows how you can invoke the generic method above to swap the content of two arrays of integers:

Get Visual Basic® 2010 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.