VB.Net Tutorial/Data Type/Wrapped Type — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:54, 26 мая 2010
Show .Net Command Types
<source lang="vbnet">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</source>
A: System.Int16 B: System.Int32 C: System.Int64 D: System.Single E: System.Double F: System.Char
Use Equal to compare Data type
<source lang="vbnet">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</source>
True True True False
Wrapped Type
<source lang="vbnet">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</source>
Integer = System.Int32 String = System.String Boolean = System.Boolean Single = System.Single