C# Convert ToSByte(String, IFormatProvider)

Description

Convert ToSByte(String, IFormatProvider) converts the specified string representation of a number to an equivalent 8-bit signed integer, using the specified culture-specific formatting information.

Syntax

Convert.ToSByte(String, IFormatProvider) has the following syntax.


[CLSCompliantAttribute(false)]/*from  w w  w .  ja  va2 s  .c o m*/
public static sbyte ToSByte(
  string value,
  IFormatProvider provider
)

Parameters

Convert.ToSByte(String, IFormatProvider) has the following parameters.

  • value - A string that contains the number to convert.
  • provider - An object that supplies culture-specific formatting information.

Returns

Convert.ToSByte(String, IFormatProvider) method returns An 8-bit signed integer that is equivalent to value.

Example


using System;//from  w w  w  .ja  v a  2s  .c  om
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( "12345" ));
        Console.WriteLine( Convert.ToSByte( "12345", provider ) );
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version