Say I have enum as follows (taken from MSDN example):
enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
I can then use is in the code as follows:
int today = (int)Days.Sun;
Question:
Can I evaluate enums? Say I have a variable Day whose value is “Sun”.
Will Days.Day evaluate to Days.Sun?
Thanks!
Please don’t get hung up on the days example and tell me I should use comparison etc…i am looking to replace the usage of arrays with enums as it is more compact. So what I am looking for is essentially an ability to retrieve values from enum similar to an array:
myArray[Day] where day will evaluate to array key….
Am I right in saying you’ve got:
and you want to get back the value
Days.Sun?If so, use: