Passing Interfaces As Method Arguments

One of the most powerful features when working with interfaces is that methods can receive interfaces as parameters. This means that you can pass in any object as these parameters so long as it implements the given interface. The following example shows a method that accepts an argument of type IList, meaning that any object implementing the IList interface can be accepted:

image

This is with no doubt one of the most important features in programming by contracts with interfaces.

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.