Related Articles
Difference between UInt16, UInt32 and UInt64 in C#
• Last Updated : 26 May, 2020

UInt16: This Struct is used to represents 16-bit unsigned integer. The UInt16 can store only positive value only which ranges from 0 to 65535.

Example :

## C#

 `// C# program to show the  ` `// UInt16 struct ` `using` `System; ` `using` `System.Text; ` ` `  `public` `class` `GFG{ ` `     `  `    ``// Main Method ` `    ``static` `void` `Main(``string``[] args) ` `    ``{ ` ` `  `        ``//printing minimum & maximum values ` `        ``Console.WriteLine(``"Minimum value of UInt16: "` `                          ``+ UInt16.MinValue); ` `        ``Console.WriteLine(``"Maximum value of UInt16: "` `                          ``+ UInt16.MaxValue); ` `        ``Console.WriteLine(); ` `         `  `        ``// Int16 array ` `        ``UInt16[] arr1 = { 13, 0, 1, 3, 7}; ` `         `  `        ``foreach` `(UInt16 i ``in` `arr1) ` `        ``{ ` `            ``Console.WriteLine(i); ` `        ``} ` `    ``} ` `}`

Output:

```Minimum value of UInt16: 0
Maximum value of UInt16: 65535

13
0
1
3
7
```

UInt32: This Struct is used to represents 32-bit unsigned integer. The UInt32 can store only positive value only which ranges from 0 to 4294967295.

Example :

## C#

 `// C# program to show the  ` `// UInt32 struct ` `using` `System; ` `using` `System.Text; ` ` `  `public` `class` `GFG{ ` `     `  `    ``// Main Method ` `    ``static` `void` `Main(``string``[] args) ` `    ``{ ` ` `  `        ``// printing minimum & maximum values ` `        ``Console.WriteLine(``"Minimum value of UInt32: "` `                          ``+ UInt32.MinValue); ` `        ``Console.WriteLine(``"Maximum value of UInt32: "` `                          ``+ UInt32.MaxValue); ` `        ``Console.WriteLine(); ` `         `  `        ``// Int32 array ` `        ``UInt32[] arr1 = { 13, 0, 1, 3, 7}; ` `         `  `        ``foreach` `(UInt32 i ``in` `arr1) ` `        ``{ ` `            ``Console.WriteLine(i); ` `        ``} ` `    ``} ` `}`

Output:

```Minimum value of UInt32: 0
Maximum value of UInt32: 4294967295

13
0
1
3
7
```

UInt64: This Struct is used to represents 64-bit unsigned integer. The UInt64 can store only positive value only which ranges from 0 to 18,446,744,073,709,551,615.

Example :

## C#

 `// C# program to show the  ` `// UInt64 struct ` `using` `System; ` `using` `System.Text; ` ` `  `public` `class` `GFG{ ` `     `  `    ``// Main Method ` `    ``static` `void` `Main(``string``[] args) ` `    ``{ ` ` `  `        ``// printing minimum & maximum values ` `        ``Console.WriteLine(``"Minimum value of UInt64: "` `                          ``+ UInt64.MinValue); ` `        ``Console.WriteLine(``"Maximum value of UInt64: "` `                          ``+ UInt64.MaxValue); ` `        ``Console.WriteLine(); ` `         `  `        ``// Int64 array ` `        ``UInt64[] arr1 = { 13, 0, 1, 3, 7}; ` `         `  `        ``foreach` `(UInt64 i ``in` `arr1) ` `        ``{ ` `            ``Console.WriteLine(i); ` `        ``} ` `    ``} ` `}`

Output:

```Minimum value of UInt64: 0
Maximum value of UInt64: 18446744073709551615

13
0
1
3
7
```

Difference between UInt16, UInt32 and UInt64 in C#

My Personal Notes arrow_drop_up
Recommended Articles
Page :