我在C#中声明了一个字符串变量,就像Windows应用程序中的VS2010 Express一样,
string strVariable = string.Empty;
//ContextUtil.DeactivateOnReturn = true;
try
{
XmlDocument xmlSourceDoc = new XmlDocument();
xmlSourceDoc.LoadXml(strXmlDocument);
strVariable = xmlSourceDoc.DocumentElement.GetAttribute("attire");
在进行调试时,我要strVariable
观看,它就像
当前上下文中不存在名称'strVariable'。
当我观看时,还有一件事xmlSourceDoc.DocumentElement.GetAttribute("attire")
我得到了结果。
可能是什么问题?
答案 0 :(得分:0)
重新构建您的解决方案并尝试。
在添加上面的行之后,您的项目似乎无法正确构建。
答案 1 :(得分:0)
您是否在代码中使用该变量而不是定义它?很多时候,对于未使用的变量,它们会被编译器修剪掉,因为你没有做任何影响控制流或数据状态的事情。尝试使用另一行来测试它是否为== String.Empty,如果是这样的话,那么就应该对它进行操作......应该欺骗编译器包含它。