Mega Code Archive

 
Categories / VB.Net / Development
 

Convert ToByte (String, Int32) converts string in a specified base to 8-bit unsigned integer

Class Sample    Public Shared Sub Main()         Dim value As String = SByte.MinValue.ToString("X")         Try            Dim number As Byte = Convert.ToByte(value, 16)            Console.WriteLine("0x{0} converts to {1}.", value, number)         Catch e As OverflowException            Console.WriteLine("Unable to convert '0x{0}' to a byte.", value)         End Try        End Sub End Class