2

I wrote a console test program, it should call a method and returns value. but i didn't use of final variable. when i test it i couldn't Add variable to watch section. this error appears in watch window

The name 'myvariable' does not exist in the current context 

My code:

  var myvariable =  SyncService.ModelToXml(tables);

modelToXml is a simple method. but when i changed to this i could watch myvariable.

 var myvariable =  SyncService.ModelToXml(tables);
 var anothervariable = myvariable;

so i tried this code:

 var xxxx = 1000;

i couldn't watch xxxx too. i've this question that when we don't use of variables, .net will remove them in compile mode? yes or not?? if not what's the reason that i can't watch it...

4

1 回答 1

9

optimize是的,如果设置了该选项,编译器会删除未使用的变量。您可以在项目设置下编辑此设置。

打开项目的属性页面。

单击构建属性页面。

修改优化代码属性。

于 2013-07-21T07:28:36.880 回答