各位大侠高手,小弟初学C#,碰到这个重载问题,请各位大侠各予指教,小弟不甚感激..
报错信息:No overload for method 'Company' takes '1' argumentsusing System;
using System.Collections.Generic;
using System.Text;namespace Chapter04
{
    class Company
    {
        private string strName;
        public string Name
        {
            get { return strName; }
            set { strName = value; }
        }
        private string strShortName;        public string ShortName
        {
            get { return strShortName; }
            set { strShortName = value; }
        }        private string strAddress;        public string Address
        {
            get { return strAddress; }
            set { strAddress = value; }
        }
        public Company(string name, string shortName, string address)
        {
            this.strName = name;
            this.strShortName = shortName;
            this.strAddress = address;
        }
        
        static void Main(string[] args)
        {
            Company company = new Company("上海交通大学");
            Console.WriteLine(company.Name);
            company=new Company("上海交通大学","交大");
            Console.WriteLine(company.Name+""+company.ShortName);
        }
       
    }}

解决方案 »

  1.   

    在这段后面加上 
           public Company(string name, string shortName, string address) 
            { 
                this.strName = name; 
                this.strShortName = shortName; 
                this.strAddress = address; 
            } 
            public Company(string name) 
            { 
                this.strName = name; 
                this.strShortName = ""; 
                this.strAddress = ""; 
            } 
            public Company(string name, string shortName) 
            { 
                this.strName = name; 
                this.strShortName = shortName; 
                this.strAddress = ""; 
            }