Visual Studio中:请调试器知道函数不会导致"副作用" [英] Visual Studio: Make debugger aware that a function doesn't cause "side effects"

查看:107
本文介绍了Visual Studio中:请调试器知道函数不会导致"副作用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对象,我有通过监视窗口观看漂亮很多次函数的输出。
的问题是,我必须每次我一步,因为时间按下刷新按钮的这种表达会产生副作用,不会被评为的。
有什么办法来标记功能的东西,如[DoesNotCauseSideEffects]所以自动手表可每次我让了一步评价它?



我。编码VS2008或2010年C#



编辑:
中的函数看起来像这样和那样,你可以看到,而不是原因任何毒副作用。(X,Y,Z都是双打)

 公共重写字符串的ToString()
{
返回{+ x.ToString(00)+,+ y.ToString(00)+,+ z.ToString(00)+};
}


解决方案

您可以追加,AC 来监视表达式,系统将自动刷新值:

  X。的ToString(),AC 

有关详细信息和其他的格式说明的。


I have an object i have to watch a function output of pretty many times through the watch window. The problem is that i have to press the refresh button every time i step because "this expression causes side effects and will not be evaluated". Is there any way to tag a function with something like [DoesNotCauseSideEffects] so the watch automatically can evaluate it every time i make a step?

I'm coding C# in VS2008 or 2010.

Edit: The function looks like this and does, as you can see, not cause any side effects.(x,y,z are all doubles)

public override string ToString()
{
    return "{ " + x.ToString(".00") + ", " + y.ToString(".00") + ", " + z.ToString(".00") + "}";
}

解决方案

You can append ,ac to the watch expression to have it automatically refresh the value:

x.ToString(),ac

See MSDN for more information and other format specifiers.

这篇关于Visual Studio中:请调试器知道函数不会导致"副作用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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