# Inconsistent accessibility: parameter type is less accessible than method

I have a level class in which I make a new turret. I give the turret the level class as parameter. So far so good. Then in the Update function of the Turret I call a function Shoot(), which has that level parameter it got at the moment I created it.

But from that moment it gives the following error:

Inconsistent accessibility: parameter type 'Space_Game.Level' is less accessible than method 'Space_Game.GameObject.Shoot(Space_Game.Level, string)'

All I know it has something to do with not thr right protection level or something like that.

The level class:

    public Level(Game game, Viewport viewport)
{
_game = game;
_viewport = viewport;
_turret = new Turret(_game, "blue", this);
_turret.SetPosition((_viewport.Width / 2).ToString(), (_viewport.Height / 2).ToString());
}


The Turret Class:

        public Turret(Game game, String team, Level level)
:base(game)
{
_team = team;
_level = level;

switch (_team)
{
case "blue":
_maxFrameCounter = 10;
break;
default:
break;
}

_frameCounter = 0;
_currentFrame = 0;
_currentFrameMultiplier = 1;
}

public override void Update()
{
base.Update();

SetRotation();
Shoot(_level, "turret");
}


The Shoot Function (Which is in GameObject class. The Turret Class inherited the GameObject Class. (Am I saying that right?)):

protected void Shoot(Level level, String type)
{
MouseState mouse = Mouse.GetState();
if (mouse.LeftButton == ButtonState.Pressed)
{
switch (_team)
{
case "blue":
switch (type)
{
case "turret":
TurretBullet _turretBullet = new TurretBullet(_game, _team);
break;
default:
break;
}
break;
default:
break;
}
}
}


What you pasted as Level class is just public constructor, you probably have something like this

class Level


when you should have

public class Level


explanation: someone could use your Turret class from their assembly, and inherit from it, at that point they could call Shoot method (because its protected, so only inherited types can call it), but they do not have access to Level class, since it was not public (therefore not avaliable in different assembly)

• Ah yes. That seems to fix it. I changed all my classes to public classes. Is that save to do that, or should I keep it at class and only change it to public class where needed? Thanks already! – DijkeMark Jul 10 '12 at 20:22
• No make all classes public, you really don't need to worry about that, this is only good when you are writing libraries and don't wont others to see your internal classes (if you dont specifie access modifier on class it's internal) – Kikaimaru Jul 11 '12 at 7:25