SByte.Parse converts string to its 8-bit signed integer : sbyte « Data Types « C# / C Sharp






SByte.Parse converts string to its 8-bit signed integer

 
using System;
public class MainClass{
    public static void Main(){

        string[] values = { "-116", "  -3", "+120", "(1111)", "1111", "-130" };
        
        foreach (string value in values)
        {
           try {
              Console.WriteLine("Converted '{0}' to the SByte value {1}.",
                                value, SByte.Parse(value));
           }
           catch (FormatException) {
              Console.WriteLine("'{0}' cannot be parsed successfully by SByte type.",
                                value);
           }                              
           catch (OverflowException) {
              Console.WriteLine("'{0}' is out of range of the SByte type.",
                                value);
           }                                                                        
        }
    }
}

   
  








Related examples in the same category

1.SByte.MaxValue Represents the largest value of SByte.
2.SByte.MinValue Represents the smallest value of SByte.
3.SByte.Parse(String,IFormatProvider) converts string to its 8-bit signed integer
4.SByte.Parse(String, NumberStyles) converts string to its 8-bit signed integer
5.Parse value with trailing sign
6.SByte.Parse(String, NumberStyles, IFormatProvider) converts string to its 8-bit signed integer.
7.SByte.ToString(IFormatProvider) converts numeric value to string with culture-specific format
8.SByte.ToString(String) converts numeric value to string using the specified format.
9.SByte.ToString(String, IFormatProvider) converts numeric value to string using the specified format
10.SByte.ToString converts the numeric value to string
11.SByte.TryParse(String, NumberStyles, IFormatProvider, SByte) tries to convert string to SByte
12.SByte.TryParse(String, SByte) tries to convert string to its SByte