How to convert Type to Enum and to integer eventually?

  • Thread starter Thread starter diffident
  • Start date Start date
D

diffident

Guest
I have an enum declared as below:

--

public enum UserTypes
{
User,
Admin,
Regulator,
Executor
}

--

I have a method as below:

protected void EnableUserType(Type userType)
{
//is it possible to get the integer constant value from userType and store it
//in the below variable?

int idx = 0;

if (IsUserTypeOnList[idx])
(IsUserTypeOnList[idx] = false;
else
(IsUserTypeOnList[idx] = true;
}

---


I call the above method using below client call. I cannot change the below call, so, somehow I need to modify above method to satisfy my needs.

EnableUserType(typeof(Regulator)));


I am having hard time converting Type object to UserTypes constant.


Any pointers?

Continue reading...
 
Back
Top