C# Int64 ToString()

Description

Int64 ToString() converts the numeric value of this instance to its equivalent string representation.

Syntax

Int64.ToString() has the following syntax.


public override string ToString()

Returns

Int64.ToString() method returns The string representation of the value of this instance, consisting of a minus 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 Int64 value using the default ToString() method.


// w  ww  . j  a va2 s . c  o m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    long 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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version