Convert.ToChar (Object) converts object to a Unicode character. : Convert to Char « Development « VB.Net






Convert.ToChar (Object) converts object to a Unicode character.

  
Class Sample
   Public Shared Sub Main()

        Dim values() As Object = { "r"c, "s", CByte(83), 77,2010, #3/10/2009#, Nothing }
        Dim result As Char
        
        For Each value As Object In values
           Try
              result = Convert.ToChar(value)
              Console.WriteLine("The {0} value {1} converts to {2}.", _ 
                                value.GetType().Name, value, result)
           Catch e As FormatException
              Console.WriteLine(e.Message)
           Catch e As InvalidCastException
              Console.WriteLine("InvalidCastException")
           Catch e As OverflowException
              Console.WriteLine("OverflowException")
           Catch e As NullReferenceException
              Console.WriteLine("NullReferenceException")
           End Try
        Next
    End Sub
End Class

   
    
  








Related examples in the same category

1.Convert.ToChar (Byte) converts 8-bit unsigned integer to Unicode character.
2.Convert.ToChar (Int16) converts 16-bit signed integer to Unicode character.
3.Convert.ToChar (Int32) converts 32-bit signed integer to Unicode character.
4.Convert.ToChar (Int64) converts 64-bit signed integer to Unicode character.
5.Convert.ToChar (SByte) converts 8-bit signed integer to Unicode character.
6.Convert.ToChar (String) converts the first character of a string to a Unicode character.
7.Convert.ToChar(String,IFormatProvider) converts the first character of string to a Unicode character with culture format
8.Convert.ToChar (UInt16) converts 16-bit unsigned integer to Unicode character.
9.Convert.ToChar (UInt32) converts 32-bit unsigned integer to Unicode character.
10.Convert.ToChar (UInt64) converts 64-bit unsigned integer to Unicode character.