C# Convert ToString(UInt16, IFormatProvider)
Description
Convert ToString(UInt16, IFormatProvider)
converts
the value of the specified 16-bit unsigned integer to its equivalent string
representation, using the specified culture-specific formatting information.
Syntax
Convert.ToString(UInt16, IFormatProvider)
has the following syntax.
[CLSCompliantAttribute(false)]//w w w. j av a 2 s . c o m
public static string ToString(
ushort value,
IFormatProvider provider
)
Parameters
Convert.ToString(UInt16, IFormatProvider)
has the following parameters.
value
- The 16-bit unsigned integer to convert.provider
- An object that supplies culture-specific formatting information.
Returns
Convert.ToString(UInt16, IFormatProvider)
method returns The string representation of value.
Example
using System;/*w ww . j av a2 s .c om*/
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( (UInt16)12345, provider ) );
}
}
The code above generates the following result.