Difference of two 'uint'
- by vanslly
When you attempt to declare an unsigned variable in C#.NET with a value outside its value range it is flagged as a compiler error, but if you produce a negative value at runtime and assign it to that variable at runtime the value wraps.
uint z = -1; // Will not compile
uint a = 5;
uint b = 6;
uint c = a - b; // Will result in uint.MaxValue
Is there a good reason why unsigned variables wrap in such a situation instead of throwing an exception?
Thanks.