Doing assignment in Break condition

送分小仙女□ 提交于 2019-12-13 09:26:26

问题


While testing something, I had to replace string (many times!) while feeling lazy to stop debugger and write up my code. Instead I thought I can do this in Break condition to see if it works.

So the break condition looks like this:

(someString = someString.Replace(".xx.", ".yy.")) != ""

Which would evaluate to true every time.

But it doesn't do the assignment. Can someone explain why the condition is evaluated correctly, but assignment never happens?


回答1:


You should do this in the Watch or Immediate windows instead. The purpose of the Break condition is to break when an expression is true, not to continuously change a real value.

It's quite a bizarre need IMHO.



来源:https://stackoverflow.com/questions/23406399/doing-assignment-in-break-condition

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