long keyword in C#

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

C# uint keyword:

In C#, long is a keyword which is utilized to proclaim a variable that can store a marked whole number an incentive between the scope of – 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. the long keyword is a moniker of System.Int64.

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

Syntax:

    long variable_name = value;

C# code to exhibit an example of long keyword:

Here, we are proclaiming a long factor num, introducing it with the worth 12345 and printing its worth, type and size of a long kind variable.

using System;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //variable declaration
            long 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 long variable: " + sizeof(long));
            //printing minimum & maximum value of long
            Console.WriteLine("Min value of long: " + long.MinValue);
            Console.WriteLine("Max value of long: " + long.MaxValue);

            //hit ENTER to exit
            Console.ReadLine();
        }
    }
}

Output:

num: 12345
Type of num: System.Int64
Size of a long variable: 8
Min value of long: -9223372036854775808
Max value of long: 9223372036854775807

Leave a Comment

error: Alert: Content is protected!!