P
puzzlecracker
I have string value, and I want to check if enum contains it..
Say I have enum MyTest {
Foo=1,
Bar
}
and is using pass string argument="Foo"; I'd like to check if it in
the enum.
Now I do the following, but I suspect there is an easier way:
foreach (MyTest t in Enum.GetValues(typeof(MyTest )))
{
if (argument== t.ToString())
{
//DO SOMETHING
}
}
Thanks
Say I have enum MyTest {
Foo=1,
Bar
}
and is using pass string argument="Foo"; I'd like to check if it in
the enum.
Now I do the following, but I suspect there is an easier way:
foreach (MyTest t in Enum.GetValues(typeof(MyTest )))
{
if (argument== t.ToString())
{
//DO SOMETHING
}
}
Thanks