Int16::ToString Method (IFormatProvider^)
Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- provider
-
Type:
System::IFormatProvider^
An IFormatProvider that supplies culture-specific formatting information.
Return Value
Type: System::String^The string representation of the value of this instance as specified by provider.
Implements
IConvertible::ToString(IFormatProvider^)The ToString(IFormatProvider^) method formats an Int16 value in the default ("G", or general) format by using the NumberFormatInfo object of a specified culture. If you want to specify a different format or the current culture, use the other overloads of the ToString method, as follows:
To use format | For culture | Use the overload |
|---|---|---|
Default ("G") format | Default (current) culture | |
A specific format | Default (current) culture | |
A specific format | A specific culture |
The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:
For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.
For more information about formatting, see Formatting Types in the .NET Framework.
The provider parameter is an IFormatProvider implementation whose IFormatProvider::GetFormat method returns a NumberFormatInfo object. Typically, provider is a NumberFormatInfo object or a CultureInfo object. The NumberFormatInfo object provides culture-specific information about the format of the string returned by this method. If provider is null, this instance is formatted with the NumberFormatInfo object for the current culture.
The following example iterates an array of Int16 values and displays each of them to the console by calling the Int16::ToString(IFormatProvider^) method with different format providers. Because of the simple formatting defined by the default "G" format specifier, the formatted strings produced for each Int16 value are identical regardless of the value of the provider parameter.
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1