Questions on using enums as parameters and if/else conditions
Posted
by dotnetdev
on Stack Overflow
See other posts from Stack Overflow
or by dotnetdev
Published on 2010-05-10T22:44:30Z
Indexed on
2010/05/10
22:54 UTC
Read the original article
Hit count: 230
c#
Hi,
Is it possible to do the following with an enum in C#?:
Pass in to a method a selected value of the enum (eg if an enum has members such as Red, Green, Orange, I can pass in Colors.Red).
In the method body of the above method which accepts an enum, I can say if (Enum == Colors.Red).
What would be the syntax for this? I've always seemed to have stalled on this.
© Stack Overflow or respective owner