C # unsigned int default value

What is the default value of unsigned int in C #?

For ex: int, its 0, I want to know for unsigned int, will unsigned int support assigning it a null value?

+7
source share
3 answers

Use this to understand:

default(uint); //0 

To assign it a null value, do you need to use Nullable<uint> or just uint? . Now if you have uint? , you can do the same to see that it supports a null value.

 default(uint?); //null 
+28
source

It is zero, and you cannot set it to null. However, can you assign null to int? or uint? , also known as Nullable<Int32> and Nullable<UInt32> .

+12
source

The default value for any structure, including unsigned int ( [mscorlib]System.UInt32 ), is all-zeros, which is 0 for uint.

You cannot assign null to any structure, but you can use Nullable<uint> (aka uint? ) If you need a uint that can be set to null.

+3
source

All Articles