Single value parse: NumberStyles.AllowParentheses
Imports System.Globalization
Module modMain
Public Sub Main()
Dim byteString As String
byteString = "-(22)"
ParseString(byteString, NumberStyles.Integer)
ParseString(byteString, NumberStyles.AllowParentheses)
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