Inconsistent accessability error C#

Started by
2 comments, last by Moe 14 years, 1 month ago
Error 1 Inconsistent accessibility: parameter type 'G2DBase.Level' is less accessible than method 'G2DBase.Game1.DrawLevel(G2DBase.Level)' C:\Users\Karlovsky\Documents\Visual Studio 2008\Projects\G2DBase\G2DBase\Game1.cs 94 24 G2DBase I am currently working on a small set of C# and XNA classes/functions to save me time making simple games. This is the function causing my problem.

protected void DrawLevel(Level L)
        {
            foreach (ObjectBase O in L.objects)
            {
                spriteBatch.Draw(O.image, O.position, Color.White);
            }
        }

other related code A basic object class

namespace G2DBase
{
    class ObjectBase
    {
        public Vector2 position;
        public bool visable;
        public bool corporeal;
        public Texture2D image;

        public ObjectBase(Vector2 Sposition, bool Svisable, bool Scorporeal,Texture2D picture)
        {
            position = Sposition;
            visable = Svisable;
            corporeal = Scorporeal;
            image = picture;
        }
        public void Update()
        {

        }
       
    }
}

A level class. Meant for making simple 2D level objects.

namespace G2DBase
{
    class Level
    {
        public List<ObjectBase> objects;
        public int height;
        public int width;
        public char[] Background;
        public Level(int h, int w, char[] BackG)
        {
            height = h;
            width = w;
            Background = BackG;
            objects = new List<ObjectBase>();
        }

        public void ParseLevel()
        {
        }

        public void UpdateLevel()
        {
            foreach (ObjectBase item in objects)
            {
                item.Update();
            }
        }

       
        public void DeleteLevel()
        {
            
        }
    }
}

I am still fairly new to C# as I have never encountered this problem before. Any help is greatly appreciated.
---------------------------------------------------------------------------------------Exercise, eat right and be the best you can be!Translation: Play video games for finger streangth and eat lots of hot pockets to be at top programming efficiency.
Advertisement
Sounds like you are missing a public access modifier somewhere, like on one of the classes. What's happening is it is trying to call a method with a parameter of G2DBase.Level, when it can't get to/use it because it isn't accessible.

I could be off base, but try making your Level and ObjectBase classes public.
That did it. I wasn't aware that stating classes as public could actually make a difference.

Much thanks
---------------------------------------------------------------------------------------Exercise, eat right and be the best you can be!Translation: Play video games for finger streangth and eat lots of hot pockets to be at top programming efficiency.
They most definitely can. Feel free to read more about them here.

This topic is closed to new replies.

Advertisement