SByte.Parse converts string in a culture-specific format to its 8-bit signed integer : SByte « Data Types « VB.Net






SByte.Parse converts string in a culture-specific format to its 8-bit signed integer

 

Imports System.Globalization

Module Example
   Public Sub Main()
      Dim nf As New NumberFormatInfo()
      nf.NegativeSign = "~" 

      Dim values() As String = { "-1", "+12", "~16", "  1", "~255" }
      Dim providers() As IFormatProvider = { nf, CultureInfo.InvariantCulture }

      For Each provider As IFormatProvider In providers
         Console.WriteLine("Conversions using {0}:", CObj(provider).GetType().Name)
         For Each value As String In values
            Try
               Console.WriteLine("   Converted '{0}' to {1}.", _
                                 value, SByte.Parse(value, provider))
            Catch e As FormatException
               Console.WriteLine("   Unable to parse '{0}'.", value)   
            Catch e As OverflowException
               Console.WriteLine("   '{0}' is out of range of the SByte type.", value)         
            End Try
         Next
      Next      
   End Sub
End Module

   
  








Related examples in the same category

1.Use the Sign(SByte) method to determine the sign of a SByte value and display it to the console.
2.SByte.MaxValue represents the largest possible value of SByte.
3.SByte.Parse converts string number to 8-bit signed integer.
4.SByte.Parse converts string in a style to 8-bit signed integer equivalent.
5.SByte.Parse Method converts string is in a style and culture-specific format to 8-bit signed equivalent.
6.SByte.ToString converts its string using the specified culture-specific format information.
7.SByte.ToString converts to string representation using the specified format.
8.SByte.ToString Method converts to string using the specified format and culture-specific format information.
9.SByte.TryParse tries to convert string in a style and culture-specific format to SByte
10.SByte.TryParse tries to convert string to SByte equivalent
11.Assign SByte to Integer