I have 1 string variable, have Enums and need to compare incoming string variable to Enum Values, and if it finds compares, I need to take compared Enum Key and assign to some int variable. How can I do this? I need Only Enum Key.
For Example I have :
public class Enums
{
Admin = 0,
Seller = 1,
Member = 2,
Unknown = 3
}
And Some base class:
string tech = “Member”;
foreach(string value in Enum.GetNames(typesof(Enums)))
{
If(tech == value)
{
int enumValueKey = And here I need '2'.
}}}
In Base class, I have only string type variable for example (string Admin, string Seller, string Member, string Unknown). If It finds 1 comparison , then should write Key in int value , the same value as was found in Enums.
Thanks a lot