C# Convert ToString(String, IFormatProvider)

Description

Convert ToString(String, IFormatProvider) returns the specified string instance; no actual conversion is performed.

Syntax

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


public static string ToString(
  string value,
  IFormatProvider provider
)

Parameters

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

  • value - The string to return.
  • provider - An object that supplies culture-specific formatting information. This parameter is ignored.

Returns

Convert.ToString(String, IFormatProvider) method returns value is returned unchanged.

Example


using System;//from  w  w  w . j av  a  2  s. c o 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.ToString( "12345" ));
        Console.WriteLine( Convert.ToString( "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