How to find out the current overflow-checking context?

只谈情不闲聊 提交于 2019-12-08 15:59:19

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2873765/how-to-find-out-the-current-overflow-checking-context

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!