Main(string[] args) 参数可否保留给 Form1 来使用?我写一支小程式想用cmd执行 AP.exe 123 
要怎麽做这参数123可以被Form1来调用呢?    

解决方案 »

  1.   

    保存起来,
    public class program
    {
        public static string[] s_args = new string[0];
        void Main(string[] args)
        {
            s_args = args;
        }
    }
    使用的时候
    program.s_args[0] ....
      

  2.   

    你的Appliction.Run(new Form1());修改为
     Form1 _Form1 =new Form1();
     _Form1.Tag =args;
    Application.Run(_Form1);在FORM1里使用的为 string[] _args =(string[])this.Tag;
      

  3.   

    在Application.Run之前,想办法把参数值传递给Form1。Form1 f=new Form1();
    f.Args=args[0];
    Application.Run(f);
      

  4.   

    上面的效率低
    直接
    Environment.GetCommandLineArgs