I have the following enum type:
public enum IconColor : short
{ Red = 1, Blue, Green, Black, Pink, Yellow };
What do I need to do to be able to check the values in a foreach loop? Or check to see if the enum contains a value i.e(Pink).
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Dec 25, 2009, 10:04 AM
protected void btnCheckValue_Click(object sender, EventArgs e)
{
foreach(IconColor x in Enum.GetValues(typeof(IconColor)))
{
if (x == IconColor.Pink)
{
MessageBox.Show("Value Found!!");
break;
}
}
}