C# Int16 ToString(IFormatProvider)
Description
Int16 ToString(IFormatProvider)
converts the numeric
value of this instance to its equivalent string representation using the
specified culture-specific format information.
Syntax
Int16.ToString(IFormatProvider)
has the following syntax.
public string ToString(
IFormatProvider provider
)
Parameters
Int16.ToString(IFormatProvider)
has the following parameters.
provider
- An IFormatProvider that supplies culture-specific formatting information.
Returns
Int16.ToString(IFormatProvider)
method returns The string representation of the value of this instance as specified by provider.
Example
The following example iterates an array of Int16 values and displays each of them to the console by calling the Int16.ToString(IFormatProvider) method with different format providers.
using System.Globalization;
using System;/*from ww w .jav a 2 s.com*/
public class MainClass{
public static void Main(String[] argv){
short[] numbers = {-12345, 0, 12345, Int16.MaxValue};
CultureInfo[] providers = {new CultureInfo("en-us"),
new CultureInfo("fr-fr"),
new CultureInfo("de-de"),
new CultureInfo("es-es")};
foreach (Int16 int16Value in numbers)
{
foreach (CultureInfo provider in providers)
{
Console.Write("{0, 6} ({1}) ",
int16Value.ToString(provider),
provider.Name);
}
Console.WriteLine();
}
}
}
The code above generates the following result.