Just noticed that the unchecked context doesn't work when working with a BigInteger, for instance:
unchecked
{
// no exception, long1 assigned to -1 as expected
var long1 = (long)ulong.Parse(ulong.MaxValue.ToString());
}
unchecked
{
var bigInt = BigInteger.Parse(ulong.MaxValue.ToString());
// throws overflow exception
var long2 = (long)bigInt;
}
Any idea why that's the case? Is there something special with the way big integers are converted to other primitive integer types?
Thanks,