using System;
class Program
{
static void Main()
{
Console.WriteLine("{0}", IntPtr.Size);
const long x = 0xFFFFFFFFFFFFFFFL;
checked
{
try
{
Console.WriteLine("{0}", (nint)x);
}
catch (Exception e)
{
Console.WriteLine("{0}", e.GetType());
}
}
unchecked
{
Console.WriteLine("{0}", (nint)x);
}
}
}
Run compiled program on 32-bit:
Expected: 4 System.OverflowException -1
Actual: 4 -1 -1
Run compiled program on 64-bit:
Expected: 8 1152921504606846975 1152921504606846975
Actual: 8 -1 -1