Hey all, you may remember me asking a question regarding a snake game I was creating about two weeks ago.

Well I'm quite far now into making the game (thanks to a brilliant tutorial I found). But I've come across the error described named above.

So heres my problem;

I have a SnakeFood class that has a method called "Reposition". In the game1 class I have a method called "UpdateInGame" which calls the reposition method to load an orange that spawns in a random place every second.

My latest piece of code changed the reposition method to allow the snake I have on the screen to not be overlapped by the orange that randomly spawns.

Now I get the error (in full):

Error 1 Inconsistent accessibility: parameter type 'TheMathsSnakeGame.Snake' is less accessible than method 'TheMathsSnakeGame.SnakeFood.Reposition(TheMathsSnakeGame.Snake)' C:\Users\Tom\Documents\Visual Studio 2008\Projects\TheMathsSnakeGame\TheMathsSnakeGame\SnakeFood.cs 33 21 TheMathsSnakeGame

I understand what the errors trying to tell me but having changed the accessiblity of the methods, I still can't get it to work.

Sorry about the longwinded question.

Thanks in advance :)

Edit: Code I'm using

 (Game1 Class)
private void UpdateInGame(GameTime gameTime)
        //Calls the oranges "reposition" method every second
        if (gameTime.TotalGameTime.Milliseconds % 1000 == 0)

(SnakeFood Class)
 public void Reposition(Snake snake)
            position = new Point(rand.Next(Grid.maxHeight),     rand.Next(Grid.maxWidth));
        } while (snake.IsBodyOnPoint(position));
  • \$\begingroup\$ Some example code will help. \$\endgroup\$
    – Ray Dey
    Commented Feb 19, 2011 at 14:06
  • \$\begingroup\$ Theres too much code to copy and paste, would you like me to copy and paste the code spoken of above? \$\endgroup\$
    – user5141
    Commented Feb 19, 2011 at 14:11
  • \$\begingroup\$ You don't have to copy and paste everything, just the appropriate code that you're having issues with. \$\endgroup\$
    – Ray Dey
    Commented Feb 19, 2011 at 14:20

1 Answer 1


The accessibility levels of C# are public > protected > internal > protected internal > private. Your class' accessibility must by >= to the accessibility of the methods it contains.

  • 2
    \$\begingroup\$ +1. meaning you have a variable: TheMathsSnakeGame.Snake. This is an instantiation of some class. Make that class a public class so it's ok to pass any instantiated objects of that class as params to other class' public methods (i.e. .Reposition()) \$\endgroup\$
    – Steve H
    Commented Feb 19, 2011 at 14:38
  • \$\begingroup\$ Thank you Steve, I've just made the Snake class public instead of its default (which is private?) and it has worked :D Thank you! :) \$\endgroup\$
    – user5141
    Commented Feb 19, 2011 at 14:49
  • 1
    \$\begingroup\$ internal is the default access modifier, when none is specified (msdn.microsoft.com/en-us/library/ms173121.aspx) \$\endgroup\$
    – Ray Dey
    Commented Feb 19, 2011 at 17:50

You must log in to answer this question.