| 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 |
|
article |
|
|
|
4f733297-2503-4607-850c-15eba65fff90 |
17 |
dotnet-bot |
dotnetcontent |
|
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
BooleanorDate. -
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,
GetTypereturns 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