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.