当前上下文中不存在名称“test1" [英] The name 'test1' does not exist in the current context

查看:25
本文介绍了当前上下文中不存在名称“test1"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MVC 控制器中,我定义了一个字符串变量,但我仍然收到消息:当前上下文中不存在名称 'test1'".

In MVC controller I defined a string variable, but still I am getting message: "The name 'test1' does not exist in the current context".

这是我的代码:

public ActionResult About()
{
  string test1;
  test1 = "A";
  return View();
}

我试图在所有 3 个语句上设置断点,但它仅在返回"命令上停止.下面是一张来自 Visual Studio 2012 的断点图:

I tried to put a breakpoint on all 3 statements, but it stopped only on the "return" command. Here is a picture from Visual Studio 2012 a breakpoint:

有什么想法吗?

推荐答案

对于调试,请将构建配置更改为 Debug 而不是 Release.Release 配置可以优化您的代码并防止调试器看到一些局部变量.

For debugging, change your build configuration to Debug instead of Release. The Release configuration can optimize your code and prevent the debugger from seeing some local variables.

这篇关于当前上下文中不存在名称“test1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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