Information.TypeName(Object) Método

Definição

Retorna um valor de String que contém informações de tipo de dados sobre uma variável.Returns a String value containing data-type information about a variable.

public:
 static System::String ^ TypeName(System::Object ^ VarName);
public static string TypeName (object? VarName);
public static string TypeName (object VarName);
static member TypeName : obj -> string
Public Function TypeName (VarName As Object) As String

Parâmetros

VarName
Object

Obrigatórios.Required. Variável Object.Object variable. Se Option Strict for Off, você poderá passar uma variável de qualquer tipo de dados, exceto uma estrutura.If Option Strict is Off, you can pass a variable of any data type except a structure.

Retornos

String

Retorna um valor de String que contém informações de tipo de dados sobre uma variável.Returns a String value containing data-type information about a variable.

Exemplos

O exemplo a seguir usa a TypeName função para retornar informações de tipo de dados sobre várias variáveis.The following example uses the TypeName function to return data type information about several variables.

Dim testType As String
Dim strVar As String = "String for testing"
Dim decVar As Decimal
Dim intVar, arrayVar(5) As Integer
testType = TypeName(strVar)
' The preceding call returns "String".
testType = TypeName(decVar)
' The preceding call returns "Decimal".
testType = TypeName(intVar)
' The preceding call returns "Integer".
testType = TypeName(arrayVar)
' The preceding call returns "Integer()".

Comentários

A tabela a seguir mostra os String valores retornados pelo TypeName para conteúdos diferentes de VarName .The following table shows the String values returned by TypeName for different contents of VarName.

VarName índiceVarName contents Cadeia de caracteres retornadaString returned
tipo de 16 bits True ou False valor16-bit True or False value type Boolean"Boolean"
tipo de valor binário de 8 bits8-bit binary value type Minuciosa"Byte"
tipo de valor de caractere de 16 bits16-bit character value type º"Char"
tipo de valor de data e hora de 64 bits64-bit date and time value type Date"Date"
Tipo de referência que indica dados ausentes ou inexistentesReference type indicating missing or nonexistent data DBNull"DBNull"
tipo de valor numérico de ponto fixo de 128 bits128-bit fixed-point numeric value type Vírgula"Decimal"
tipo de valor numérico de ponto flutuante de 64 bits64-bit floating-point numeric value type Clique"Double"
tipo de valor inteiro de 32 bits32-bit integer value type Valores"Integer"
Tipo de referência que aponta para um objeto não especializadoReference type pointing to an unspecialized object Objeto"Object"
Tipo de referência que aponta para um objeto especializado criado a partir da classe objectClassReference type pointing to a specialized object created from class objectclass "objectClass""objectclass"
tipo de valor inteiro de 64 bits64-bit integer value type Completa"Long"
Tipo de referência sem objeto atualmente atribuído a eleReference type with no object currently assigned to it Nada"Nothing"
tipo de valor inteiro com sinal de 8 bits8-bit signed integer value type SByte"SByte"
tipo de valor inteiro de 16 bits16-bit integer value type Baixo"Short"
tipo de valor numérico de ponto flutuante de 32 bits32-bit floating-point numeric value type Exclusivo"Single"
Tipo de referência que aponta para uma cadeia de caracteres de 16 bitsReference type pointing to a string of 16-bit characters Strings"String"
tipo de valor inteiro sem sinal de 32 bits32-bit unsigned integer value type UInteger"UInteger"
tipo de valor inteiro sem sinal de 64 bits64-bit unsigned integer value type ULONG"ULong"
tipo de valor inteiro sem sinal de 16 bits16-bit unsigned integer value type Num"UShort"

Se VarName for uma matriz, a cadeia de caracteres retornada poderá ser qualquer uma das cadeias na tabela anterior com parênteses vazios anexados.If VarName is an array, the returned string can be any one of the strings in the preceding table with empty parentheses appended. Por exemplo, se VarName apontar para uma matriz de inteiros, TypeName retorna "Integer ()".For example, if VarName points to an array of integers, TypeName returns "Integer()".

Quando TypeName retorna o nome de um tipo de referência, como uma classe, ele retorna apenas o próprio nome, não o nome qualificado.When TypeName returns the name of a reference type such as a class, it returns only the name itself, not the qualified name. Por exemplo, se VarName apontar para um objeto da classe System.Drawing.Printing.PaperSource , TypeName retornará "PaperSource".For example, if VarName points to an object of class System.Drawing.Printing.PaperSource, TypeName returns "PaperSource". Observe que, se a variável for declarada como sendo de um determinado tipo de classe, mas não tiver um objeto atribuído a ela, TypeName retornará "Nothing".Note that if the variable is declared to be of a certain class type but does not have an object assigned to it, TypeName returns "Nothing".

Aplica-se a

Confira também