w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Casting UInt32 to Int32: Different compiler results

The way you have the code laid out, you are simply dealing with the compiler's ability to determine the potential outcome. Nothing really changes. As the error message suggests to you, you could do this and arrive at the exact same result:

unchecked { UInt32 oneLineCastBack =
(UInt32)(Int32)UInt32.MaxValue; }

The only difference between the two examples you give is that the second one is a direct cast of the const value to Int32 which the compiler can immediately recognize as an error.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.