A UInteger data type holds any value between 0 and 4,294,967,295 (ref. MSDN).
If I try this code in VB.NET, I get a compiler error:
Dim Test As UInteger = &HFFFFFFFF Error: "Constant expression not representable in type 'UInteger'.
Why I can't set 0xFFFFFFFF (4,294,967,295) to a UInteger if this type can hold this value?
I believe it's because the literal &HFFFFFFFF is interpreted by the VB.NET compiler as an Integer, and that value for an Integer is a negative number (-1), which obviously can't be cast to a UInteger.
This issue is easily fixed by writing &HFFFFFFFFUI, appending the UI suffix to treat the literal as a UInteger.
You could use the MaxValue constant:
Dim Test As UInteger = UInteger.MaxValue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With