CopyPastehas never been so tasty!

Standard format specifiers for ulong value in C#

by anonymous

  • 0
  • 0
  • 0

Orignal source:

Ulong keyword:


ulong is a keyword that stores a large value and its range is 0 to 18,446,744,073,709,551,615.  In this ‘u’ means unsigned, so ulong cannot store negative values. But the difference in long and ulong is long can store both signed and unsigned value but ulong can store large value but without sign.You can declare the ulong variable like this


ulongmyUlong = 9223372036854775808;


Standard format specifiers for ulong value:


Ulong can store larger values value cannot be negative. To understand the working of ulong consider the following program. Declare and initialize the ulong variable and show it. Also declare and initialize a string type array. Now use foreach loop to iterate the array and after that we will display the string value into ulong format.


To demonstrate make a console application and write the following code and just run the application.






staticvoid Main(string[] args)



ulong value = 163249057;

// Display value using default ToString method.




// 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));





Add A Comment: