找不到类型或命名空间名称“EventArgs”(是否缺少 using 指令或程序集引用?)是什么意思?

解决方案 »

  1.   

    using System.Text;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace test
    {
       
        public partial class Form1 : Form
        {
            private string FileName = "a.txt";
            private string FileContent;       
           
            private void btnSaveFile_Click(object sender,EventArgs e)
            {
                FileInfo info = new FileInfo(FileName);
                if (!info.Exists)
                {
                    MessageBox.Show("File Doesn't Exist! Will Creat");
                }
                FileStream fs = info.open(FileMode.OpenOrCreat,FileAccess.ReadWrite,FileShare.ReadWrite);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriterLine(FileContent);
                sw.Close();
                fs.Close();
            }        private void btnLoadFile_Click(object sender, EventArgs e)
            {
                FileInfo info = new FileInfo(FileName);
                if (!info.Exists)
                {
                    MessageBox.Show("File Doesn't Exist ! Will Creat!");
                }
                FileStream fs = info.Open(FileMode.OpenOreate,FileAccess.ReadWrite,FileShare.Readwrite);
                StreamReader sr = new StreamReader(fs);
                string strContent = sr.ReadLine();
                sr.Close();
                fs.Close();
                MessageBox.Show("File Content is:"+strContent);
            }        private void btnException_Click(object sender, EventArgs e)
            {
                throw new Exception("I throw an Exception,but i don't know what's to do ,hehe!");
            }                private void HelloWorld_Load(object sender, EventArgs e)
            {
                FileInfo info = new FileInfo(FileName);
                if (!info.Exists)
                {
                    MessageBox.Show("File Does't Exist!Will Creat!");
                }
                FileStream fs = info.Open(FileMode.OpenOrCreate,FileAccess.ReadWriter,FileShare.ReadWrite);
                StreamReader sr = new StreamReader(fs);
                string StrContent = sr.ReadLine();
                sr.Close();
                fs.Close();
                this.txtContent.Text = StrContent;
                this.FileContent = StrContent;
            }
    运行时第二个EventArgs处发生之前的错误!
      

  2.   

    我又在
    namespace test 

      
        public partial class Form1 : Form 
        { 
            private string FileName = "a.txt"; 
            private string FileContent; 
    之后加了
      public class EventArgs
            { 
                public EventArgs.EventArgrs(); 
            }
    但还是不对,你帮忙看一下,谢了!
      

  3.   

    代码最后少了两个“}”
    第二个是指
    private void btnLoadFile_Click(object sender, EventArgs e) 这里么?
      

  4.   

    我给的代码不全,原代码后是有“}”的,是所有的“ EventArgs ”处都出现错误!
      

  5.   


    //你给的代码
    using System.Text; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Linq; 
    using System.Text; 
    using System.Windows.Forms; 
    //你究竟有没有"using System;"?
      

  6.   

    还真是没有using System;
    晕死,我连这都没看到……
      

  7.   

    我输入过using System; 
    但还是有问题的!
      

  8.   

    请不要把问题孤立来看。
    输入using System还有问题是可能你别的地方有错误。
    这句是必须的
      

  9.   


        public partial class Form1 : Form
        {
            public Form1()//楼主的代码没有这个????
            {
                InitializeComponent();
             }
         }

     
      

  10.   

    我试过了,有和没有
    public Form1() 
            { 
                InitializeComponent(); 
            } 
    效果是一样的
      

  11.   

    现在只有一个错误了:
    public  class EventArgs
            { 
                  public  EventArgs.EventArgs() ; 
            }
    在这一句中显示错误“类、结构或接口成员声明中的标记“(”无效”,怎么改啊?
      

  12.   

    把他放在和form1类平行的位置.
    楼主着段代码是干什么用的?重写吗?
      

  13.   

    namespace test 

      
        public partial class Form1 : Form 
        { 
            private string FileName = "a.txt"; 
            private string FileContent; 
      }
      public class EventArgs 
            { 
                public EventArgs.EventArgrs(); 
            } 
    }