Jump to content
  • Advertisement
Sign in to follow this  
ryt

Accessing enum from inherited class

This topic is 2090 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

In C# in my base class Weapon I have declared a enum Firestate like:

enum Firestate
{
    Fire
};
 
public class Weapon : MonoBehaviour
{
    public Firestate firestate;
};

And in a inherited class Gun I use that enum. But I get error CS0052: Inconsistent accessibility: field type 'Firestate' is less accessible than field 'Weapon.firestate'.
When I remove public from firestate there is no error but then I cant use it in Gun since it is private.

Edited by ryt

Share this post


Link to post
Share on other sites
Advertisement
The error is pretty descriptive. Your class Weapon has a public enum field, but the enum itself is not public. How could anyone actually use the firestate field if they can't access the values in the Firestate enum? Make the Firestate enum 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!