Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out the current overflow-checking context?

Tags:

c#

.net

overflow

Is there a way to do this in C#?

So for example, if your method is called and you want to know if the caller had put the method call inside a checked block?

like image 205
theburningmonk Avatar asked May 20 '10 12:05

theburningmonk


1 Answers

checked/ unchecked blocks are always local to the method. The keywords influence how IL is generated for the statements and expressions in the block. It doesn't propagate to methods called, and there is no way to determine at run-time if a method was called from such a block. It's a compile-time feature.

like image 92
dtb Avatar answered Nov 11 '22 16:11

dtb