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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version