The following is done with .Net 5:
The following line is not allowed by the compiler as the number exceeds the maximum long value:
long value = 123456789123456789123456789123456789; // <= Not allowed by compiler
However, the following line is allowed by both the compiler and by the runtime:
Decimal value = 123456789123456789.123456789123456789m; // No compile time error, no runtime error.
The issue is, that the value is immediately truncated into 123456789123456789,12345678912. So the value is actually altered without any notice.
I would like to know if dotnet can be set up to blow up in this case as I want things to break early, at compile time at best or at least at runtime.
Anyone one out there who solved this?