Home » C#.Net

long keyword in C#

C# long keyword: Here, we are going to learn about the long keyword in C#, what is long keyword, how to use it in C#?
Submitted by IncludeHelp, on March 07, 2019

C# uint keyword

In C#, long is a keyword which is used to declare a variable that can store a signed integer value between the range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. long keyword is an alias of System.Int64.

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

Syntax:

    long variable_name = value;

C# code to demonstrate example of long keyword

Here, we are declaring a long variable num, initializing it with the value 12345 and printing its value, type and size of a long type 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




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.