Select Items from List using Array Is there a better way to write this procedure?

    public List&lt;IDenomination&gt; GetInventory(int[] denominations)
    {
        var inventory = new List&lt;IDenomination&gt;();

        foreach (var denomination in denominations)
        {
            foreach (var item in Account)
            {
                if (item.Currency == denomination)
                {
                    inventory.Add(item);
                }
            }
        }

        return inventory;
    }
You could use some linq to do this fairly easily. Converting the array to a HashSet will allow Contains to operate faster

public List&lt;IDenomination&gt; GetInventory(int[] denominations)
{
    var denoms = new HashSet&lt;int&gt;(denominations);
    return Account.Where( a =&gt; denoms.Contains(a.Currency) ).ToList();
}


This assumes that Account : IDenomination though, as does your original code. If that were not the case, you would use a .Select() prior to .ToList() in order to select the IDenomination from Account.