Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))

GetType Operator

Syntax

Dim result As System.Type = GetType(typename)

typename (required; any type)

The name of a type

Description

The GetType operator returns information about a particular type or instance, such as the name, base type, reference or value type status, COM-related GUID, namespace, and so on.

Usage at a Glance

  • Passing an instance variable to GetType generates a compiler error.

  • If you don't know the name of the type about which you'd like to get information, but you do have an object instance of that type, you can retrieve a System.Type object using the Type.GetType method.

Version Differences

The GetType operator is new to VB under .NET.

See Also

CType Function

Категории