xarzu
xarzu

Reputation: 9479

Why are these enums bad

In Visual Studio -- well, I am using Visual Studio 11 Beta, so that might be the issue -- I think I am coding enums ok. But while this works:

enter image description here

This does not work:

enter image description here

What is wrong?

Upvotes: 1

Views: 1291

Answers (3)

C# is a strong typed language. You are missing the enum name before the enum value. This should work:

return TriangleType.error;

and so on...

Upvotes: 4

McArthey
McArthey

Reputation: 1646

If you wanted to do as in your first example and return an int you could cast the value and still use the enum "names", as in:

return (int)TriangleType.scalene;

See this other SO question for more information.

Upvotes: 2

McGarnagle
McGarnagle

Reputation: 102723

Nothing to do with the VS11 beta. You just have to prefix with the enum name:

return TriangleType.error;

Upvotes: 11

Related Questions