• Advertisement
Sign in to follow this  

[.net] C# enum

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