it is a bit unusual question but I am unable to get casting error when casting numeric types. I would need to get some error like “value too short” etc. but seems that C# guards it quite well.
Could you provide me with a simple code that fails on casting? (like stackoverflow..)
it is a bit unusual question but I am unable to get casting error
Share
You can use the checked keyword to explicitly check for overflow of integral type conversions:
There is also a checked compiler flag which can make checked conversions the default.