UInt64 and "The operation overflows at compile time in checked mode" - CS0220
1073741824
is an int
, not a UInt64
.
Therefore, your multiplication overflows the limit of a 32-bit signed integer.
Add the ul
(unsigned long) suffix to either operand.
Because:
UInt64 value1 = 1073741824 * 8;
Is doing the arithmetic as a signed 32-bit integer, then converting it to an ulong
. Try:
UInt64 value1 = 1073741824UL * 8;
The UL
means that the literal is of an unsigned long. See section 2.4.4 of the C# Specification for more on literal suffixes:
If the literal is suffixed by UL, Ul, uL, ul, LU, Lu, lU, or lu, it is of type ulong