C# uint keyword: Here, we will find out about the uint keyword in C#, what is uint keyword, how to utilize it in C#?
C# uint keyword:
In C#, uint is a keyword which is utilized to announce a variable that can store an essential kind of significant worth (unsigned number) the scope of 0 to 4,294,967,295. uint keyword is an assumed name of System.UInt32.
It involves 4 bytes (32 bits) space in the memory.
Syntax:
C# code to show an example of uint keyword:
Here, we are pronouncing a uint variable num, introducing it with the worth 12345 and printing its worth, 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