Sign in to follow this  

[.net] C# enum

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

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