enum string value

  • Thread starter Thread starter puzzlecracker
  • Start date Start date
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
 
I shudder to think what the color "Ultraviolate" looks like....

lol - sounds like a title from the "somewhat dubious" section of the
video store...

Marc
 
Back
Top