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).
Enum Type
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Kirtan PatelRank #292 · 8.6K reputationPosted Dec 25, 2009, 5:04 AM EST
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;
}
}
}