Visual Basic.NET 2008 > Using Variables and Data Types
Examining Variable Types - Variables in Visual Basic 2008Besides setting the types of variables and the functions for converting between types, Visual Basic provides the GetType method, which returns a string with the variable's type (Int32, Decimal, and so on). Any variable exposes these methods automatically, and you can call them like this:
There's also a GetType operator, which accepts as an argument a type and returns a Type object for the specific data type. The GetType method and GetType operator are used mostly in If structures, like the following one:
Notice that the code doesn't reference data type names directly. Instead, it uses the value returned by the GetType operator to retrieve the type of the class System.Double and then compares this value to the variable's type with the Is (or the IsNot) keyword.
Table of Contents
|
|||||
W3computing.com Copyright 2011 © All Rights Reserved
|
|||||
| Home | Useful links | Contact us | |||||