The GetType Keyword

Each time you create an instance of a class, the .NET runtime creates an instance behind the scenes of the System.Type class that represents your object. Because in the .NET development you have the ability to inspect at runtime instances of the System.Type class (known as Reflection) and to get a reference to that System.Type, the Visual Basic programming language offers the GetType keyword that enables accomplishing both tasks. The GetType keyword has two different behaviors: The first one is an operator whereas the second one is a method; typically GetType is used in comparing two instances of an object or in accessing metadata of a type at runtime. To understand GetType, here are a few examples. Consider this first code ...

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.