C# Int16 ToString(String)
Description
Int16 ToString(String)
converts the numeric value of
this instance to its equivalent string representation, using the specified
format.
Syntax
Int16.ToString(String)
has the following syntax.
public string ToString(
string format
)
Parameters
Int16.ToString(String)
has the following parameters.
format
- A numeric format string.
Returns
Int16.ToString(String)
method returns The string representation of the value of this instance as specified by format.
Example
The following example initializes two Int16 values and displays them to the console using each of the supported standard format strings and several custom format strings.
//from w ww .j ava2 s .c o m
using System;
public class MainClass{
public static void Main(String[] argv){
Int16[] values = {-12345, 12};
string[] formats = {"C4", "D6", "e1", "E2", "F1", "G", "N1",
"P0", "X4", "000000.0000", "##000.0"};
foreach (string format in formats)
{
Console.WriteLine("'{0,2}' format specifier: {1,17} {2,17}",
format,
values[0].ToString(format),
values[1].ToString(format));
}
}
}
The code above generates the following result.