(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Show .Net Command Types
Module Module1
Sub Main()
Dim A As Short
Dim B As Integer
Dim C As Int64
Dim D As Single
Dim E As Double
Dim F As Char
Console.WriteLine("A: {0} ", A.GetType().FullName)
Console.WriteLine("B: {0} ", B.GetType().FullName)
Console.WriteLine("C: {0} ", C.GetType().FullName)
Console.WriteLine("D: {0} ", D.GetType().FullName)
Console.WriteLine("E: {0} ", E.GetType().FullName)
Console.WriteLine("F: {0} ", F.GetType().FullName)
End Sub
End Module
A: System.Int16
B: System.Int32
C: System.Int64
D: System.Single
E: System.Double
F: System.Char
Use Equal to compare Data type
Imports System.Collections
public class Test
public Shared Sub Main
Dim s1 As New String("Hello")
Dim s2 As New String("Hello")
Console.WriteLine(s1.Equals(s2))
s1 = s2
Console.WriteLine(s1.Equals(s2))
Dim n1 As New Integer()
Dim n2 As New Integer()
n1 = 10
n2 = 10
Console.WriteLine(n1.Equals(n2))
n1 = 20
Console.WriteLine(n1.Equals(n2))
End Sub
End class
True
True
True
False
Wrapped Type
Option Strict On
Public Class WrappedType
Public Shared Sub Main()
Dim intVar As Integer = 100
Dim intType As Type = intVar.GetType()
Console.WriteLine(TypeName(intVar) & " = " & intType.FullName)
Dim stringVar As String = "This is a string."
Dim stringType As Type = stringVar.GetType()
Console.WriteLine(TypeName(stringVar) & " = " & stringType. FullName)
Dim boolVar As Boolean = True
Dim boolType As Type = boolVar.GetType()
Console.WriteLine(TypeName(boolVar) & " = " & boolType. FullName)
Dim singleVar As Single = 3.1417
Dim singleType As Type = singleVar.GetType()
Console.WriteLine(TypeName(singleVar) & " = " & singleType. FullName)
End Sub
End Class
Integer = System.Int32
String = System.String
Boolean = System.Boolean
Single = System.Single