namespaces - c# Inconsistent Accessibility Prevents Private Classes as parameters for Protected Methods -
here simplified example of how want code work. please note code not compile:
namespace specificnamespace { class utilityobject { //properties } public abstract class entity { protected void dostuff(utilityobject utilityobject) { //does stuff } } // include implementations of entity } namespace generalnamespace { public static class world { public static list<specificnamespace.entity> entities = new list<specificnamespace.entity>(); } }
it doesn't compile because of line:
protected void dostuff(utilityobject utilityobject)
inconsistent accessibility: parameter type 'utilityobject' less accessable method 'entity.dostuff(utilityobject utilityobject)'
but swear, going implement entity
classes declared inside of specificnamespace
, therefore class has reference protected method entity.dostuff
have access utillityobject
. since no class outside of namespace has business knowing utilityobject
is, not want declare public. on otherhand entity
needs public entities can referred generically.
is there way around this? shortfall of c# conventions? being precious this?
try make utilityobject inner class inside entity protected accessebility level.