Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ToString Method (IFormatProvider)

SByte.ToString Method (IFormatProvider)

Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

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

public string ToString(
	IFormatProvider provider


Type: System.IFormatProvider

An object that supplies culture-specific formatting information.

Return Value

Type: System.String
The string representation of the value of this instance, as specified by provider.



The ToString(IFormatProvider) method formats an SByte value in the default ("G", or general) format of a specified culture. If you want to specify a different format or the current culture, use the other overloads of the ToString method, as follows:

To use format

For culture

Use the overload

Default ("G") format

Default (current) culture


A specific format

Default (current) culture


A specific format

A specific culture

ToString(String, IFormatProvider)

The provider parameter is an IFormatProvider implementation. Its GetFormat method returns a NumberFormatInfo object that provides culture-specific information about the format of the string returned by this method. If provider is null, the SByte value is formatted using the NumberFormatInfo object of the current culture. The only property of the NumberFormatInfo object that controls the string representation of the SByte value using the general format specifier is NumberFormatInfo.NegativeSign, which defines the character that represents the negative sign.

The provider parameter can be one of the following:

The following example defines a custom NumberFormatInfo object and assigns the "~" character to its NegativeSign property. The example then uses this custom object as well as the NumberFormatInfo object of the invariant culture to format a series of SByte values.

using System;
using System.Globalization;

public class Example
   public static void Main()
      // Define a custom NumberFormatInfo object with "~" as its negative sign.
      NumberFormatInfo nfi = new NumberFormatInfo();
      nfi.NegativeSign = "~";

      // Initialize an array of SByte values. 
      sbyte[] bytes = { -122, 17, 124 };

      // Display the formatted result using the custom provider.
      Console.WriteLine("Using the custom NumberFormatInfo object:");
      foreach (sbyte value in bytes)


      // Display the formatted result using the invariant culture.
      Console.WriteLine("Using the invariant culture:");
      foreach (sbyte value in bytes)
// The example displays the following output: 
//       Using the custom NumberFormatInfo object: 
//       ~122 
//       17 
//       124 
//       Using the invariant culture: 
//       -122 
//       17 
//       124

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
© 2015 Microsoft