Filtering a list by comparing enums against a user choice I have a list of objects where one of the properties on the object class is an enum.

The program below simply loops through each item in the list, checks an int value, then checks the enum value for that item, then adds the item to another list when the condition is met.

I am using if-else statements, I attempted to use a switch statement but it doesn't seem possible to place 2 constants on a single case.

I'd like to know if there's a better / more elegant way to do this or is what I've done sufficient in this scenario?

Program Code

// User inputs number from 1 - 5        
int SelectedOppType = Int32.Parse(Console.ReadLine());

foreach (Opportunities Opp in OpportunitiesList)
{
    if (SelectedOppType == 1 &amp;&amp; Opp.OpportunityStatusID == OpportunityStatus.Active) // Opp.OpportunityStatusID == OpportunityStatus.Draft
    {
        FilterdOppsList.Add(Opp);
    }
    else if (SelectedOppType == 2 &amp;&amp; Opp.OpportunityStatusID == OpportunityStatus.Draft)
    {
        FilterdOppsList.Add(Opp);
    }
    else if (SelectedOppType == 3 &amp;&amp; Opp.OpportunityStatusID == OpportunityStatus.Closed)
    {
        FilterdOppsList.Add(Opp);
    }
    else if (SelectedOppType == 4 &amp;&amp; (Opp.OpportunityStatusID == OpportunityStatus.Active || Opp.OpportunityStatusID == OpportunityStatus.Draft))
    {
        FilterdOppsList.Add(Opp);
    }
    else if (SelectedOppType == 5)
    {
        FilterdOppsList.Add(Opp);
    }

}

foreach (var OppItem in FilterdOppsList)
{
    Console.WriteLine(OppItem.OppText);
}

Console.ReadLine();
When SelectedOppType == 5, all values in OpportunitiesList will be added to FilterdOppsList, but only after evaluating many conditions unnecessarily. It would be better to handle this as a special case,
and add all values of OpportunitiesList in FilterdOppsList before ever entering the foreach loop.

Next, in the foreach loop, since selectedOppType doesn't change throughout the loop, regardless of the value of opp, it would make more sense to use conditionals on the value of opp.OpportunityStatusID instead of selectedOppType. You can rearrange the conditions to switch statement.

Putting it all together:

if(selectedOppType == 5)
{
    FilterdOppsList.AddRange(OpportunitiesList);
}
else
{
    foreach (Opportunities opp in OpportunitiesList)
    {
        bool shouldAdd = false;
        switch (opp.OpportunityStatusID)
        {
            case OpportunityStatus.Active:
                 shouldAdd = selectedOppType == 1 || selectedOppType == 4;
                 break;
            case OpportunityStatus.Draft:
                 shouldAdd = selectedOppType == 2 || selectedOppType == 4;
                 break;
            case OpportunityStatus.Closed:
                 shouldAdd = selectedOppType == 3;
                 break;
        }
        if (shouldAdd)
        {
            FilterdOppsList.Add(opp);
        }
    }
}