【发布时间】:2016-06-02 17:27:46
【问题描述】:
对编码相当陌生,不知道我在哪里出错了。应用程序构建但在运行时崩溃并出现错误:“对象引用未设置为对象的实例。”
如果我注释掉 test2 变量和第二个条件,那么应用程序会执行我想要的操作。当我取消注释上述内容时,我得到一个例外。
我最终需要为 30 个复选框的形式构建类似的东西。
任何帮助将不胜感激。
XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"\\LEWBWPDEV\\ComplianceXmlStorage\\test.xml");
string test1 = xDoc.SelectSingleNode("Introduction/Topic1").InnerText;
string test2 = xDoc.SelectSingleNode("Introduction/Topic2").InnerText;
if (test1 == "Yes")
{
checkBox1.CheckState = CheckState.Checked;
}
if (test2 == "Yes")
{
checkBox2.CheckState = CheckState.Checked;
}
【问题讨论】:
标签: c# .net xml xmldocument