How can I skip a value in a foreach loop if it does not match any of the values in an specific enum. Ex:
public enum IDs
{
SomeIdOne = 1001,
SomeIdTwo = 1002,
SomeIdThree = 1003
}
// one of the list items(7777) does not match what's in the IDs enum
var SomeIds = new List<IDs>() { 1002,7777,1001 };
// skip that item when looping through the list.
foreach (IDs id in SomeIds)
{
// do things with id
}
In the past I have used LINQ to filter out 0 in a similar situation, can I do something like that here?