Jump to content
  • Advertisement
Sign in to follow this  
steveworks

Inconsistent accessability error C#

This topic is 3151 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
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!