我目前正在做一些类编码,想知道我的项目出了什么问题?
class ContactPerson
{
string name;
ContactNo telNo;
public ContactPerson(string in_Name, ContactNo in_No)
{
name = in_Name;
telNo = new ContactNo();
}
public string getName()
{
return name;
}
public ContactNo getContactInfo()
{
return telNo;
}
public void setName(string in_Name)
{
name = in_Name;
}
public void setContactInfo (ContactNo in_No)
{
telNo = in_No;
}
}
}
class ContactNo
{
string contactType;
string contactNo;
public void setContactType(string in_Type)
{
contactType = in_Type;
}
public string getContactType()
{
return contactType;
}
public void setContactNo(string in_No)
{
contactNo = in_No;
}
public string getContactNo()
{
return contactNo;
}
}
}
class Program
{
static void Main(string[] args)
{
ContactNo telNo;
telNo = new ContactNo("Mobile No: ", 95656565);
ContactPerson myFriend;
myFriend = new ContactPerson("Fred Smith", telNo);
string strName;
strName = myFriend.getName();
Console.WriteLine(" " + strName);
ContactNo outContact;
outContact = myFriend.getContactInfo();
outContact.getContactType();
Console.WriteLine(outContact);
outContact.getContactNo();
Console.WriteLine(outContact);
Console.ReadLine();
}
}
}
在程序类“ telNo = new ContactNo("Mobile No: ", 95656565); ”中出现错误说不包含带2个参数的构造函数我可以知道为什么吗?