Home » C#.Net

uint keyword in C#

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

C# uint keyword

In C#, uint is a keyword which is used to declare a variable that can store an integral type of value (unsigned integer) the range of 0 to 4,294,967,295. uint keyword is an alias of System.UInt32.

It occupies 4 bytes (32 bits) space in the memory.

Syntax:

    uint variable_name = value;

C# code to demonstrate example of uint keyword

Here, we are declaring a uint variable num, initializing it with the value 12345 and printing its value, type and size of a uint type variable.

using System;
using System.Text;

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

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

Output

num: 12345
Type of num: System.UInt32
Size of a uint variable: 4
Min value of uint: 0
Max value of uint: 4294967295
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




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.