public partial class Route : Form
    {
        public List<string> picCount = new List<string>();
        public Route(string statusInfo)
        {
            InitializeComponent();
            this.listBox1.Focus();
            this.statusInfo = statusInfo;
        }
    }public class ThreadWithState
    {
        public void ThreadProc()
        {
            //这边报错, 没用0个参数          
            Route r = new Route("");
            //请问这边该怎么改?
            r.picCount...
        }
    }
求解决方法

解决方案 »

  1.   

    真能想那分明是构造函数   public Post(int Id,string title)
            {
                this.ID = Id;
                this.Title = title;
            }
            public int ID { get; set; }
            public int CategoryID { get; set; }        public string Title { get; set; }
            public string Summary { get; set; }
            public string Alias { get; set; }
            public string Content { get; set; }
            public DateTime CreateTime { get; set; }        public Category Category { get; set; }
            public ICollection<Tag> Tags { get; set; }
            public ICollection<Comment> Coments { get; set; }
        }
        Post post=new Post(1,"title")
      

  2.   

    public void fangfa() ; 
    public gouzao();你那是构造。
      

  3.   

     public class Post
        {
            public Post(int Id,string title)
            {
                this.ID = Id;
                this.Title = title;
            }        public int ID { get; set; }
            public int CategoryID { get; set; }        public string Title { get; set; }
            public string Summary { get; set; }
            public string Alias { get; set; }
            public string Content { get; set; }
            public DateTime CreateTime { get; set; }        public Category Category { get; set; }
            public ICollection<Tag> Tags { get; set; }
            public ICollection<Comment> Coments { get; set; }
        }Post post=new Post(1,"title")
      

  4.   

    Route r = new Route("aaaaaaaaaaa");给构造函数传值
      

  5.   

     Route 类 在 Program.cs 里看有没有启动 Application.Run(new  Route("dd"));
    如果是这样Application.Run(new  Route());会报错 改成 Application.Run(new  Route(""));
      

  6.   

    解决办法有2种:
    方法一,在Program中的入口实例化构造函数就必须传参: static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Route());
            }
        }方法二:
      
    public partial class Route : Form
        {
            public List<string> picCount = new List<string>();
            public Route(string statusInfo)
            {
                InitializeComponent();
                this.listBox1.Focus();
                this.statusInfo = statusInfo;
            }
        }public class ThreadWithState
        {
            public void ThreadProc()
            {
                //这边报错, 没用0个参数          
                Route r = new Route("");
                //请问这边该怎么改?
                r.picCount...
            }
        }类Route中没有默认的构造函数引起的,只要添加默认的构造函数就可以了。 
      

  7.   

    public Route(string statusInfo)
            {
                InitializeComponent();
                this.listBox1.Focus();
                this.statusInfo = statusInfo;
            }
    自定义构造函数后,当进行实例化时通过该构造函数对其进行初始化,构造函数所带参数也要在相应位置赋值。例: public Route(string statusInfo,int intIndex){} 实例化时Route GetRoute=new Route("open",0) 。参数不能空缺。不知道说得对不对,有误请指正。