Permalink
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (64 sloc) 2.94 KB
title ms.date ms.prod ms.reviewer ms.suite ms.technology ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author translation.priority.ht
GetType Operator (Visual Basic)
2015-07-20
.net
devlang-visual-basic
article
vb.GetType
VB
GetType operator
GetType keyword
4f733297-2503-4607-850c-15eba65fff90
17
dotnet-bot
dotnetcontent
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

GetType Operator (Visual Basic)

Returns a xref:System.Type object for the specified type. The xref:System.Type object provides information about the type such as its properties, methods, and events.

Syntax

GetType(typename)  

Parameters

Parameter Description
typename The name of the type for which you desire information.

Remarks

The GetType operator returns the xref:System.Type object for the specified typename. You can pass the name of any defined type in typename. This includes the following:

  • Any Visual Basic data type, such as Boolean or Date.

  • Any .NET Framework class, structure, module, or interface, such as xref:System.ArgumentException?displayProperty=nameWithType or xref:System.Double?displayProperty=nameWithType.

  • Any class, structure, module, or interface defined by your application.

  • Any array defined by your application.

  • Any delegate defined by your application.

  • Any enumeration defined by Visual Basic, the .NET Framework, or your application.

If you want to get the type object of an object variable, use the xref:System.Type.GetType%2A?displayProperty=nameWithType method.

The GetType operator can be useful in the following circumstances:

  • You must access the metadata for a type at run time. The xref:System.Type object supplies metadata such as type members and deployment information. You need this, for example, to reflect over an assembly. For more information, see xref:System.Reflection?displayProperty=nameWithType.

  • You want to compare two object references to see if they refer to instances of the same type. If they do, GetType returns references to the same xref:System.Type object.

Example

The following examples show the GetType operator in use.

[!code-vbVbVbalrOperators#26]

See Also

Operator Precedence in Visual Basic
Operators Listed by Functionality
Operators and Expressions