Format ulong with the standard format specifiers in CSharp

Description

The following code shows how to format ulong with the standard format specifiers.

Example


using System;/*from w  w w  .j a va  2s.c o  m*/

public class Example
{
   public static void Main()
   {
      ulong value = 163249057;
      // Display value using default ToString method.
      Console.WriteLine(value.ToString());      
      Console.WriteLine();

      // Define an array of format specifiers.
      string[] formats = { "G", "C", "D", "F", "N", "X" };
      // Display value using the standard format specifiers.
      foreach (string format in formats)
         Console.WriteLine("{0} format specifier: {1,16}",format, value.ToString(format));         
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var