Mega Code Archive

 
Categories / VB.Net / Development
 

Convert ToChar (Int16) converts 16-bit signed integer to Unicode character

Class Sample    Public Shared Sub Main()         Dim numbers() As Short = { Int16.MinValue, 0, 40, 160, 255, 1028, _                                    2011, Int16.MaxValue }         Dim result As Char         For Each number As Short In numbers            Try               result = Convert.ToChar(number)               Console.WriteLine("{0} converts to '{1}'.", number, result)            Catch e As OverflowException               Console.WriteLine("{0} is outside the range of the Char data type.", _                                 number)            End Try         Next        End Sub End Class