日期:2014-05-18 浏览次数:20998 次
using System;
using System.Drawing;
using System.Windows.Forms;
// csc /t:winexe
namespace demo
{
  class program
  {
    static void Main(string[] args)
    {
      Form frm = new Form();
      TextBox textBox = new TextBox();
      textBox.Location = new Point(2,2);
      textBox.Width = 200;
      if (args.Length > 0)
        textBox.Text = args[0];
      
      frm.Controls.Add(textBox);
      
      Application.Run(frm);
    
    }
    
  };
}
------解决方案--------------------
//修改c#的Program.cs里面的Main函数
static void Main(params string[] args) 
{ 
//... 
//...其余不变
Application.Run(new Form1(args));
} 
//...
//在Form1里面 添加
public Form1(params string[] args)
{
   //...
   //args就是命令行参数了
   textBox1.Text = String.Join(" ",args);
}