Convert.ToSByte(String, IFormatProvider) Method in C#

CsharpServer Side ProgrammingProgramming

The Convert.ToSByte() method in C# converts the specified string representation of a number to an equivalent 8-bit signed integer, using the specified culture-specific formatting information.


Following is the syntax −

public static sbyte ToSByte (string val, IFormatProvider provider);

Above, the parameter value is a string that contains the number to convert. A provider parameter is an object that supplies culture-specific formatting information.


Let us now see an example to implement the Convert.ToSByte() method −

using System;
using System.Globalization;
public class Demo {
   public static void Main(){
      CultureInfo cultures = new CultureInfo("en-US");
      String str = "-2";
      Console.WriteLine("Converted sbyte value...");
      sbyte res = Convert.ToSByte(str, cultures);
      Console.Write("{0}", res);


This will produce the following output −

Converted sbyte value...
Published on 06-Nov-2019 10:11:36