C# Convert ToSByte(Object, IFormatProvider)
Description
Convert ToSByte(Object, IFormatProvider)
converts
the value of the specified object to an 8-bit signed integer, using the specified
culture-specific formatting information.
Syntax
Convert.ToSByte(Object, IFormatProvider)
has the following syntax.
[CLSCompliantAttribute(false)]/*from w ww. j av a 2 s . c o m*/
public static sbyte ToSByte(
Object value,
IFormatProvider provider
)
Parameters
Convert.ToSByte(Object, IFormatProvider)
has the following parameters.
value
- An object that implements the IConvertible interface.provider
- An object that supplies culture-specific formatting information.
Returns
Convert.ToSByte(Object, IFormatProvider)
method returns An 8-bit signed integer that is equivalent to value, or zero if value is null.
Example
using System;// w w w . jav a 2 s . co m
using System.Globalization;
class MainClass
{
public static void Main( )
{
NumberFormatInfo provider = new NumberFormatInfo();
provider.NegativeSign = "neg ";
provider.PositiveSign = "pos ";
provider.NumberDecimalSeparator = ".";
provider.NumberGroupSeparator = ",";
provider.NumberGroupSizes = new int[ ] { 3 };
provider.NumberNegativePattern = 0;
Console.WriteLine( Convert.ToSByte((object) "12345" ));
Console.WriteLine( Convert.ToSByte((object) "12345", provider ) );
}
}
The code above generates the following result.