获取消息:
“错误 1 可访问性不一致:参数类型 'Assignment_5.Address' 的可访问性低于方法 'Assignment_5.ContactManager.AddContact(string, string, Assignment_5.Address)' C:\Users\OscarIsacson\documents\visual studio 2012\Projects\Assignment 5\分配 5\ContactFiles\ContactManager.cs 24 21 分配 5"
这是方法代码(所有类都是公共的):
private List<Contact> m_contactRegistry;
public bool AddContact(string firstName, string lastName, Address adressIn)
{
Contact contactIn = new Contact(firstName, lastName, adressIn);
m_contactRegistry.Add(contactIn);
return true;
}
public bool AddContact(Contact ContactIn)
{
m_contactRegistry.Add(ContactIn);
return true;
}
和地址类:
namespace Assignment_5
{
public class Address
{
private string m_street;
private string m_zipCode;
private string m_city;
private Countries m_country;
public Address() : this (string.Empty, string.Empty, "Göteborg")
{
}
public Address(string street, string zip, string city)
: this(street, zip, city, Countries.Sweden)
{
}
public Address(string street, string zip, string city, Countries country)
{
}
public string Street;
public string City;
public string ZipCode;
public Countries Country;
/// <summary>
/// This function simply deletes the "_" from country names as saves in the enum.
/// </summary>
/// <returns>the country name whitout the underscore char.</returns>
public string GetCountryString()
{
string strCountry = m_country.ToString();
strCountry = strCountry.Replace("_", " ");
return strCountry;
}
/// <summary>
/// Method that overrides the ToString method
/// </summary>
/// <returns>Formatted string with address detail on one line</returns>
public override string ToString()
{
return string.Format("{0, -25} {1,-8} {2, -10} {3}", m_street, m_zipCode, m_city, GetCountryString());
}
}
}