Discussion:
Inconsistent accessibility...property type ... is less accessible than property ...
(too old to reply)
mp
2016-12-17 20:07:20 UTC
Permalink
dont understand this
I can't specify public or private in an interface
so I don't understand why i get this error:

interface IBuilding
{...
List<IBuildingComponent > Components { get; set; }
}
public class Building : IBuilding
{...
public List<IBuildingComponent> Components { get; set; }
//Inconsistent accessibility:prop type 'List<IBuildingComponent>' is
less accessible than property 'Building.Components'
}

if i try adding public to the interface i get 'modifier not valid'

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
mp
2016-12-17 20:25:22 UTC
Permalink
Post by mp
dont understand this
I can't specify public or private in an interface
interface IBuilding
{...
List<IBuildingComponent > Components { get; set; }
}
public class Building : IBuilding
{...
public List<IBuildingComponent> Components { get; set; }
//Inconsistent accessibility:prop type 'List<IBuildingComponent>' is
less accessible than property 'Building.Components'
}
if i try adding public to the interface i get 'modifier not valid'
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
figured it out, the whole interface has to be marked public not the
individual members
public interface IBuilding{...}


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Registered User
2016-12-17 21:07:06 UTC
Permalink
Post by mp
dont understand this
I can't specify public or private in an interface
interface IBuilding
{...
List<IBuildingComponent > Components { get; set; }
}
public class Building : IBuilding
{...
public List<IBuildingComponent> Components { get; set; }
//Inconsistent accessibility:prop type 'List<IBuildingComponent>' is
less accessible than property 'Building.Components'
}
if i try adding public to the interface i get 'modifier not valid'
You must have done this...
interface IBuilding
{
...
public List<IBuildingComponent > Components { get; set; }
}
instead of this ...
public interface IBuilding
{
...
List<IBuildingComponent > Components { get; set; }
}
Post by mp
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Arne Vajhøj
2016-12-17 22:28:32 UTC
Permalink
Post by mp
dont understand this
I can't specify public or private in an interface
interface IBuilding
{...
List<IBuildingComponent > Components { get; set; }
}
public class Building : IBuilding
{...
public List<IBuildingComponent> Components { get; set; }
//Inconsistent accessibility:prop type 'List<IBuildingComponent>' is
less accessible than property 'Building.Components'
}
if i try adding public to the interface i get 'modifier not valid'
It is really a little quirk in C#.

All interface members are public.

And it is not even valid to explicit specify public.

Your only control is the accessibility if the interface
itself.

Arne

Loading...