C# SByte ToString(String, IFormatProvider)
Description
SByte ToString(String, IFormatProvider)
converts
the numeric value of this instance to its equivalent string representation
using the specified format and culture-specific format information.
Syntax
SByte.ToString(String, IFormatProvider)
has the following syntax.
public string ToString(
string format,
IFormatProvider provider
)
Parameters
SByte.ToString(String, IFormatProvider)
has the following parameters.
format
- A standard or custom numeric format string.provider
- An object that supplies culture-specific formatting information.
Returns
SByte.ToString(String, IFormatProvider)
method returns The string representation of the value of this instance as specified by format
and provider.
Example
The following example displays both a positive and a negative SByte value using the standard numeric format specifiers and a number of specific CultureInfo objects.
using System;/*ww w . j a v a 2 s.c o m*/
using System.Globalization;
public class Example
{
public static void Main()
{
CultureInfo[] cultures = { CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.CreateSpecificCulture("fr-FR"),
CultureInfo.CreateSpecificCulture("es-ES") };
sbyte positiveNumber = 123;
sbyte negativeNumber = -123;
string[] specifiers = {"G", "C", "D3", "E3", "F", "N", "P", "X2"};
foreach (string specifier in specifiers)
{
foreach (CultureInfo culture in cultures)
Console.WriteLine("{0,2} format using {1} culture: {2, 16} {3, 16}",
specifier, culture.Name,
positiveNumber.ToString(specifier, culture),
negativeNumber.ToString(specifier, culture));
}
}
}
The code above generates the following result.