ulong

In this chapter you will learn:

  1. ulong literal
  2. Calculate with ulong
  3. ulong format

ulong literal

using System;//from   j  a v  a2 s .c o  m

public class MainClass{
    public static void Main() {
        unsigned long ulVal = 0776745ul;  // Unsigned long value
        Console.WriteLine(ulVal);

    }
}

Calculate with ulong

using System;//ja  v  a  2 s . co m

class MainClass
{
    static void Main(string[] args)
    {
        ulong loopCount = 0;
        ulong factorial = 1;
        loopCount = 23;
        for( ulong i = loopCount; i > 0; i-- )
        {
            factorial *= i;
        }
        Console.WriteLine( "{0}! = {1}", loopCount, factorial );

    }
}

ulong format

Display value using the standard format specifiers for ulong value.

using System;//from j a  v a 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));         
   }
}

Next chapter...

What you will learn in the next chapter:

  1. decimal type
  2. decimal literials
Home » C# Tutorial » Byte, Integer, Long
Integer Family
Integer ranges
byte
Convert to byte
Parse string to byte
byte format
byte octal and hexadecimal
byte binary operation
byte overflow with unchecked
int
int value
Compare int value
int calculation
int value overflow
int binary operation
Parse string to int value
Format int value
int in binary, octal and hexadecimal
long
long value calculation
ulong