NumberStyles.Integer
Imports System.Globalization
Module modMain
Public Sub Main()
Dim byteString As String
byteString = "0x21"
ParseString(byteString, NumberStyles.Integer)
ParseString(byteString, NumberStyles.AllowHexSpecifier)
End Sub
Private Sub ParseString(value As String, style As NumberStyles)
Dim number As SByte
Try
number = SByte.Parse(value, style, NumberFormatInfo.CurrentInfo)
Console.WriteLine("SByte.Parse(""{0}"", {1})) = {2}", value, style.ToString, number)
Catch e As Exception
Console.WriteLine("'{0}' and {1} throw a {2}", value, style.ToString, e.GetType.Name)
End Try
End Sub
End Module
Related examples in the same category