如何找出当前溢出检查上下文? [英] How to find out the current overflow-checking context?

查看:222
本文介绍了如何找出当前溢出检查上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法做到这一点在C#?

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?

推荐答案

检查 / 选中块是局部的给方法。关键字影响如何IL是在块中的语句和前pressions产生。它不传播的方法调用,并且没有方法来确定在运行时,如果一个方法是从这样的块调用。这是一个编译时的功能。

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.

这篇关于如何找出当前溢出检查上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆