C# Int32 ToString()
Description
Int32 ToString()
converts the numeric value of this instance
to its equivalent string representation.
Syntax
Int32.ToString()
has the following syntax.
public override string ToString()
Returns
Int32.ToString()
method returns The string representation of the value of this instance, consisting of a
negative sign if the value is negative, and a sequence of digits ranging from
0 to 9 with no leading zeroes.
Example
The following example displays an Int32 value using the default ToString() method. It also displays the string representations of the Int32 value that results from using a number of standard format specifiers.
using System;/* www . j a va 2s. co m*/
public class MainClass{
public static void Main(String[] argv){
int value = -12345678;
// Display value using default ToString method.
Console.WriteLine(value.ToString());
// Display value using some standard format specifiers.
Console.WriteLine(value.ToString("G"));
Console.WriteLine(value.ToString("C"));
Console.WriteLine(value.ToString("D"));
Console.WriteLine(value.ToString("F"));
Console.WriteLine(value.ToString("N"));
Console.WriteLine(value.ToString("X"));
}
}
The code above generates the following result.