SByte.Parse Method (String, NumberStyles, IFormatProvider)

Converts the string representation of a number that is in a specified style and culture-specific format to its 8-bit signed equivalent.

This method is not CLS-compliant.   The CLS-compliant alternative is Parse(String,NumberStyles,IFormatProvider).

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static sbyte Parse (
	string s,
	NumberStyles style,
	IFormatProvider provider
/** @attribute CLSCompliantAttribute(false) */ 
public static SByte Parse (
	String s, 
	NumberStyles style, 
	IFormatProvider provider
public static function Parse (
	s : String, 
	style : NumberStyles, 
	provider : IFormatProvider
) : sbyte
Not applicable.



A string that contains the number to convert.


A bitwise combination of the NumberStyles values that indicates the permitted format for s.


An IFormatProvider object that supplies culture-specific formatting information about s.

Return Value

An 8-bit signed byte value that is equivalent to the number specified in the s parameter.

Exception typeCondition


style is not a NumberStyles value.


style is not a combination of AllowHexSpecifier and HexNumber.


s is a null reference (Nothing in Visual Basic).


s is not in a format that is compliant with style.


s represents a number that is less than MinValue or greater than MaxValue.

The style parameter can include all NumberStyles values. The value supplied to the style parameter defines the possible content of s as follows:


If the s parameter is the string representation of a hexadecimal number, it cannot be preceded by any decoration (such as 0x or &h) that differentiates it as a hexadecimal number. This causes the parse operation to throw an exception.

The provider parameter is an IFormatProvider object. Its GetFormat method returns a NumberFormatInfo object that provides culture-specific information about the format of s. There are three ways to use the provider parameter to supply custom formatting information to the parse operation:

  • You can pass the actual NumberFormatInfo object that provides formatting information. (Its implementation of GetFormat simply returns itself.)

  • You can pass a CultureInfo object that specifies the culture whose formatting is to be used. Its NumberFormat property provides formatting information.

  • You can pass a custom object that implements IFormatProvider and uses its GetFormat method to instantiate and return the NumberFormatInfo object that provides formatting information.

If provider is a null reference (Nothing in Visual Basic), the NumberFormatInfo object for the current culture is used.

The following example illustrates the use of the Parse(String,NumberStyles,IFormatProvider) method to convert various string representations of numbers to signed integer values.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0