C# SByte ToString(IFormatProvider)

Description

SByte ToString(IFormatProvider) converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

Syntax

SByte.ToString(IFormatProvider) has the following syntax.


public string ToString(
  IFormatProvider provider
)

Parameters

SByte.ToString(IFormatProvider) has the following parameters.

  • provider - An object that supplies culture-specific formatting information.

Returns

SByte.ToString(IFormatProvider) method returns The string representation of the value of this instance, as specified by provider.

Example

The following example defines a custom NumberFormatInfo object and assigns the "~" character to its NegativeSign property.


using System;/*from   w w  w . j av  a2s  . co m*/
using System.Globalization;

public class Example
{
   public static void Main()
   {
      NumberFormatInfo nfi = new NumberFormatInfo();
      nfi.NegativeSign = "~";

      sbyte[] bytes = { -122, 17, 124 };

      foreach (sbyte value in bytes)
         Console.WriteLine(value.ToString(nfi));

      foreach (sbyte value in bytes)
         Console.WriteLine(value.ToString(NumberFormatInfo.InvariantInfo));
   }
}

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