VB.Net Tutorial/Reflection/GetType

Материал из VB Эксперт
Перейти к: навигация, поиск

GetType Method

<source lang="vbnet">Option Strict On Public Module GetTypeMethod

  Public Sub Main
     Dim firstName As String = "John"
     Dim firstNameType As Type = firstName.GetType()
     
     Console.WriteLine("The type of the variable firstname is {0}.", _
                       firstNameType)
  End Sub

End Module</source>

The type of the variable firstname is System.String.

Get variable type

<source lang="vbnet">Imports System Module MyModule

 Sub Main()
   Dim i As Integer = 100
   Dim j As Int32 = i
   Console.WriteLine("Integer: {0}", GetType(Integer).FullName)
   Console.WriteLine("Int32:   {0}", GetType(Int32).FullName)
 End Sub

End Module</source>

Integer: System.Int32
Int32:   System.Int32