' Sample for the Convert class summary.
Imports System
Class Sample
Public Shared Sub Main()
Dim nl As String = Environment.NewLine
Dim str As String = "{0}Return the Int64 equivalent of the following base types:{0}"
Dim xBool As Boolean = False
Dim xShort As Short = 1
Dim xInt As Integer = 2
Dim xLong As Long = 3
Dim xSingle As Single = 4F
Dim xDouble As Double = 5.0
Dim xDecimal As Decimal = 6D
Dim xString As String = "7"
Dim xChar As Char = "8"c ' '8' = hexadecimal 38 = decimal 56
Dim xByte As Byte = 9
' The following types are not CLS-compliant.
' Dim xUshort As System.UInt16 = 120
' Dim xUint As System.UInt32 = 121
' Dim xUlong As System.UInt64 = 122
' Dim xSbyte As System.SByte = 123
' The following type cannot be converted to an Int64.
' Dim xDateTime As System.DateTime = DateTime.Now
Console.WriteLine(str, nl)
Console.WriteLine("Boolean: {0}", Convert.ToInt64(xBool))
Console.WriteLine("Int16: {0}", Convert.ToInt64(xShort))
Console.WriteLine("Int32: {0}", Convert.ToInt64(xInt))
Console.WriteLine("Int64: {0}", Convert.ToInt64(xLong))
Console.WriteLine("Single: {0}", Convert.ToInt64(xSingle))
Console.WriteLine("Double: {0}", Convert.ToInt64(xDouble))
Console.WriteLine("Decimal: {0}", Convert.ToInt64(xDecimal))
Console.WriteLine("String: {0}", Convert.ToInt64(xString))
Console.WriteLine("Char: {0}", Convert.ToInt64(xChar))
Console.WriteLine("Byte: {0}", Convert.ToInt64(xByte))
Console.WriteLine("DateTime: There is no example of this conversion because")
Console.WriteLine(" a DateTime cannot be converted to an Int64.")
'
Console.Write("{0}The following types are not supported: ", nl)
Console.WriteLine("UInt16, UInt32, UInt64, and SByte")
End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'Return the Int64 equivalent of the following base types:
'
'Boolean: 0
'Int16: 1
'Int32: 2
'Int64: 3
'Single: 4
'Double: 5
'Decimal: 6
'String: 7
'Char: 56
'Byte: 9
'DateTime: There is no example of this conversion because
' a DateTime cannot be converted to an Int64.
'
'The following types are not supported: UInt16, UInt32, UInt64, and SByte
'