请问这是什么错误,谢谢

yux007 2004-10-29 11:50:50
D:\code\C#\OperateXML\OperateXML\Class1.cs(25): An object reference is required for the nonstatic field, method, or property 'OperateXML.Class1.Read1()'


using System;
using System.Xml;
using System.IO;


namespace OperateXML
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
///
public XmlDocument m_xmlDocument = new XmlDocument();

[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Read1();

}

public void Read1()
{
m_xmlDocument.Load(@"D:\code\C#\OperateXML\OperateX");
XmlNode xmlNode = m_xmlDocument.SelectSingleNode("AttrName");
string m_strPersonID = xmlNode.ChildNodes [0].InnerText;
Console.WriteLine (m_strPersonID);
}
}
}


请大侠指教,谢谢!
...全文
71 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fellowcheng 2004-10-29
  • 打赏
  • 举报
回复
up
yux007 2004-10-29
  • 打赏
  • 举报
回复
大家看看啊
lr2651 2004-10-29
  • 打赏
  • 举报
回复
public 和 void 中间加static 就成了
Jeffeng 2004-10-29
  • 打赏
  • 举报
回复
静态的方法中只能调用静态的方法。
把public void Read1()->public static void Read1()试试。
wingnal 2004-10-29
  • 打赏
  • 举报
回复
Main()不能这么调用函数吧,应该是实例化类才对阿

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧