ulong keyword in C#

C# ulong keyword: Here, we will find out about the ulong keyword in C#, what is ulong keyword, how to utilize it in C#?

C# ulong keyword:

In C#, ulong is a keyword which is utilized to pronounce a variable that can store an unsigned whole number an incentive between the scope of 0 to 18,446,744,073,709,551,615. ulong keyword is a nom de plume of System.UInt64.

It involves 8 bytes (64 bits) space in the memory.


    ulong variable_name = value;

C# code to show an example of ulong keyword:

Here, we are announcing a ulong variable num, instating it with the worth 12345 and printing its worth, type and size of a ulong type variable.

using System;
using System.Text;

namespace Test
    class Program
        static void Main(string[] args)
            //variable declaration
            ulong num = 12345;

            //printing value
            Console.WriteLine("num: " + num);
            //printing type of variable
            Console.WriteLine("Type of num: " + num.GetType());
            //printing size
            Console.WriteLine("Size of a ulong variable: " + sizeof(ulong));
            //printing minimum & maximum value of ulong
            Console.WriteLine("Min value of ulong: " + ulong.MinValue);
            Console.WriteLine("Max value of ulong: " + ulong.MaxValue);

            //hit ENTER to exit


num: 12345
Type of num: System.UInt64
Size of a ulong variable: 8
Min value of ulong: 0
Max value of ulong: 18446744073709551615

Leave a Comment

error: Alert: Content is protected!!