Returns the specified string converted to a sbyte value.
- s
- A string containing the value to convert. The string is interpreted using the System.Globalization.NumberStyles.Integer style.
The sbyte value obtained from s.
Type Reason ArgumentException s is a null reference. FormatException s is not in the correct style. OverflowException s represents a number greater than sbyte.MaxValue or less than sbyte.MinValue.
This version of sbyte.Parse(string) is equivalent to sbyte.Parse(string) (s, System.Globalization.NumberStyles.Integer, null).
The string s is parsed using the formatting information in a System.Globalization.NumberFormatInfo initialized for the current system culture.
Note: for more information, see System.Globalization.NumberFormatInfo.CurrentInfo.This method is not CLS-compliant. For a CLS-compliant alternative use short.Parse(string) (string).
This example demonstrates the sbyte.Parse(string)(string) method.
C# Example
using System; public class SByteParseClass { public static void Main() { string str = " 100 "; Console.WriteLine("String: \"{0}\" <SByte> {1}", str,SByte.Parse(str)); } }The output is
String: " 100 " <SByte> 100
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0