[.net] C# enum

Started by
1 comment, last by capn_midnight 16 years, 7 months ago
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?
Advertisement
Yes.
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?

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

This topic is closed to new replies.

Advertisement