C# Int32 and UInt32 Differences: Here, we will find out about the contrasts between C# Int32 and C# UInt32 information types.
C# Int32 and C# UInt32
In C#, Int32 known as a marked whole number of 4 bytes which can store the two kinds of qualities including negative and positive between the scopes of – 2147483648 to +2147483647.
UInt32 known as an unsigned number of 4 bytes which can store just positive qualities between the scopes of 0 to 4294967295.
Contrasts somewhere in the range of ‘Int32’ and ‘UInt32’
Int32 | UInt32 |
---|---|
Int32 stands for signed integer. | UInt32 stands for an unsigned integer. |
It’s the capacity to store the value is -2147483648 to +2147483647. | It’s the capacity to store the value is 0 to 4294967295. |
It can store negative and positive integers. | It can store only positive integers. |
It occupies 4-bytes space in the memory. | It also occupies 4-bytes space in the memory. |
Declaration syntax: Int32 variable; | Declaration syntax: UInt32 variable; |
Example:
Example:
In this example, to clarify the contrasts somewhere in the range of Int32 and UInt32 in C#, we are printing their base and most extreme qualities, we are likewise pronouncing two clusters – arr1 is a marked number sort and arr2 is an unsigned whole number sort. Instating the exhibits with relating negative and positive qualities dependent on their ability.
using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
//Int32 value range
Console.WriteLine("Int32 value capacity...");
Console.WriteLine("Min: {0}, Max: {1}\n", Int32.MinValue, Int32.MaxValue);
//UInt32 value range
Console.WriteLine("UInt32 value capacity...");
Console.WriteLine("Min: {0}, Max: {1}\n", UInt32.MinValue, UInt32.MaxValue);
//Int32 array
Int32[] arr1 = { -2147483648, 0, 12320009, 2147480000, 2147483647 };
Console.WriteLine("UInt32 array elements...");
foreach (Int32 num in arr1)
{
Console.WriteLine(num);
}
Console.WriteLine();
//UInt32 array
UInt32[] arr2 = { 0, 100, 23000, 4294960000, 4294967295 };
Console.WriteLine("UInt32 array elements...");
foreach (UInt32 num in arr2)
{
Console.WriteLine(num);
}
//hit ENTER to exit
Console.ReadLine();
}
}
}
Output:
Int32 value capacity...
Min: -2147483648, Max: 2147483647
UInt32 value capacity...
Min: 0, Max: 4294967295
UInt32 array elements...
-2147483648
0
12320009
2147480000
2147483647
UInt32 array elements...
0
100
23000
4294960000
4294967295