how to search an enum variable for a specific member?
I have declared an enum as
enum PaymentFrequency : int
{
Monthly = 12,
Quarterly = 4,
SemiAnnual = 4,
Annual = 1
};
in the method I am writing, the parameter passed is any one of items in the enum (say Annual).
How to search an enum variable for 'Annual' and get the value which is 1 here.
thanks
nath
Re: how to search an enum variable for a specific member?
You don't search for enum values. They simply are. If the variable is of that enum type, then the variable's value would be the value you are looking for,.
-tg
Re: how to search an enum variable for a specific member?
Quote:
Originally Posted by bnathvbdotnet
I have declared an enum as
enum PaymentFrequency : int
{
Monthly = 12,
Quarterly = 4,
SemiAnnual = 4,
Annual = 1
};
in the method I am writing, the parameter passed is any one of items in the enum (say Annual).
How to search an enum variable for 'Annual' and get the value which is 1 here.
thanks
nath
cast it to (int)
or use a switch