System.Byte.ToString Method

Converts the value of the current byte object to its equivalent string representation using the specified format and culture-specific formatting information.

Syntax

public string ToString (string format, IFormatProvider provider)

Parameters

format
A standard or custom numeric format string.
provider
An object that supplies culture-specific formatting information.
format
A standard or custom numeric format string.
provider
An object that supplies culture-specific formatting information.

Returns

The string representation of the current byte object, formatted as specified by the format and provider parameters.

Exceptions

TypeReason
FormatException format is invalid.

Remarks

The byte.ToString(string, IFormatProvider) method formats a byte value in a specified format of a specified culture. To format a number by using the default ("G") format of the current culture, call the byte.ToString method. To format a number by using a specified format of the current culture, call the byte.ToString(string) method.

The format parameter can be either a standard or a custom numeric format string. All standard numeric format strings other than "R" (or "r") are supported, as are all custom numeric format characters. If format is null or an empty string (""), the return value of this method is formatted with the general numeric format specifier ("G").

The provider parameter is an object that implements the IFormatProvider interface. Its IFormatProvider.GetFormat(Type) method returns a System.Globalization.NumberFormatInfo object that provides culture-specific information about the format of the string that is returned by this method. The object that implements IFormatProvider can be any of the following:

If provider is null or a System.Globalization.NumberFormatInfo object cannot be obtained from provider, the return value is formatted using the System.Globalization.NumberFormatInfo object for the thread current culture. For information about the thread current culture, see System.Threading.Thread.CurrentCulture.

The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0