C# Byte ToString(String, IFormatProvider)
Description
Byte ToString(String, IFormatProvider)
converts the
value of the current Byte object to its equivalent string representation
using the specified format and culture-specific formatting information.
Syntax
Byte.ToString(String, IFormatProvider)
has the following syntax.
public string ToString(
string format,
IFormatProvider provider
)
Parameters
Byte.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
Byte.ToString(String, IFormatProvider)
method returns The string representation of the current Byte object, formatted as specified
by the format and provider parameters.
Example
The following example uses the standard "N" format string and four different CultureInfo objects to display the string representation of a byte value to the console.
using System;/*from w w w. j a v a2s .c o m*/
using System.Globalization;
public class MainClass {
public static void Main(String[] argv){
byte byteValue = 250;
CultureInfo[] providers = {new CultureInfo("en-us"),
new CultureInfo("fr-fr"),
new CultureInfo("es-es"),
new CultureInfo("de-de")};
foreach (CultureInfo provider in providers) {
Console.WriteLine("{0} ({1})", byteValue.ToString("N2", provider), provider.Name);
}
}
}
The code above generates the following result.