Error inconsistent accessibility method C# -
get message:
"error 1 inconsistent accessibility: parameter type 'assignment_5.address' less accessible method 'assignment_5.contactmanager.addcontact(string, string, assignment_5.address)' c:\users\oscarisacson\documents\visual studio 2012\projects\assignment 5\assignment 5\contactfiles\contactmanager.cs 24 21 assignment 5 "
this method code(all classes public):
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; }
and address class:
namespace assignment_5 { public class address { private string m_street; private string m_zipcode; private string m_city; private countries m_country; public address() : (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> /// function deletes "_" country names saves in enum. /// </summary> /// <returns>the country name whitout underscore char.</returns> public string getcountrystring() { string strcountry = m_country.tostring(); strcountry = strcountry.replace("_", " "); return strcountry; } /// <summary> /// method overrides tostring method /// </summary> /// <returns>formatted string address detail on 1 line</returns> public override string tostring() { return string.format("{0, -25} {1,-8} {2, -10} {3}", m_street, m_zipcode, m_city, getcountrystring()); } } }
the address
class either protected
, private
or internal
error. note classes internal
default in c#.
Comments
Post a Comment