Convert.ChangeType : Convert « Development « VB.Net






Convert.ChangeType

   


Imports System

Public Class ChangeTypeTest

    Public Shared Sub Main()
        Dim d As [Double] = - 2.345
        Dim i As Integer = CInt(Convert.ChangeType(d, GetType(Integer)))

        Console.WriteLine(i)
        Dim s As String = "12/12/98"
        Dim dt As DateTime = CType(Convert.ChangeType(s, GetType(DateTime)), DateTime)

        Console.WriteLine(dt)
    End Sub 'Main
End Class 'ChangeTypeTest

   
    
    
  








Related examples in the same category

1.Convert numeric string to SByte without a format provider
2.Convert numeric string to SByte with a format provider.
3.Converting strings to numbers in base
4.Convert.ToBase64CharArray converts 8-bit unsigned integer array to Unicode character array
5.Convert the Char array back to a Byte array
6.Convert.ToBase64String converts 8-bit unsigned integers to string encoded with base-64 digits.
7.Convert string by different base
8.Convert.ToDateTime (Object) converts object to a DateTime object.
9.Convert.ToDateTime Method (Object, IFormatProvider) converts object to DateTime using culture-specific format
10.Convert.ToDateTime(String) converts string to date and time value.
11.Convert.ToDateTime(String, IFormatProvider) converts string to date and time, using culture-specific format
12.Convert single value to decimal
13.Convert hex string to Int16
14.Convert hex string to int64
15.Convert Long to Integer
16.Convert double to Integer
17.Convert BigInteger to Integer
18.Convert decimal to Integer