System.Int16.ToString Method

Converts the numeric value of this instance 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 numeric format string.
format
A numeric format string.
provider
An object that supplies culture-specific formatting information.

Returns

The string representation of the value of this instance as specified by format and provider.

Exceptions

TypeReason
FormatException format is invalid.

Remarks

The short.ToString(string, IFormatProvider) method formats an short value in a specified format by using the System.Globalization.NumberFormatInfo object of a specified culture. If you want to use default format or culture settings, use the other overloads of the short.ToString(string) method, as follows:

Default ("G") format

Default (current) culture

short.ToString

Default ("G") format

A specific culture

short.ToString(IFormatProvider)

A specific format

Default (current) culture

short.ToString(string)

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 string returned by this method is formatted with the general numeric format specifier ("G").

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

The provider parameter is an IFormatProvider implementation. 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 with the System.Globalization.NumberFormatInfo for the current culture.

Requirements

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