Jump to content
  • Advertisement
Sign in to follow this  
ELFanatic

[.net] C# enum

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

I'm trying to create this method.
        private Point bounds(int dx, int dy)
        {
            Point dest;
            enum piecewiseBounds { beyondCircle = 866, outerCircle = 315, top = 270, innerCircle = 0};
            if (dx > piecewiseBounds.beyondCircle)
            {

            }
            else if (dx <= piecewiseBounds.outerCircle)
            {

            }
            else if (dx < piecewiseBounds.top)
            {

            }
            else if (dx < piecewiseBounds.innerCircle)
            {
            }
            return dest;
        }

but I get an array of errors when I have enum inside the function, none when it's in the class definition. Is it not possible to define an enum inside a function? I really only need it within the scope of that function. I guess I'm supposed to use const?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ELFanatic
Is it not possible to define an enum inside a function?

correct, not possible
Quote:
I really only need it within the scope of that function.

define it as private in member in the class. It will still have class-level scope, but it won't be accessible any higher than that.
Quote:
I guess I'm supposed to use const?

wut?

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!