Sign in to follow this  

Inconsistent accessability error C#

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this