public static List <T> Filter <T>(this List <T> sourceList, FilterDel <T> del) { List <T> tempList = new List <T>(); foreach (T item in sourceList) { if (del(item)) { tempList.Add(item); } } return(tempList); }
public List <Bar> FilterCondition(int index, List <Bar> bars) { string input; FilterDel selectBars = null; switch (index) { case 0: input = Interaction.InputBox(Resource1.MinimalFilter); selectBars += FilterByPerc; break; case 1: input = Interaction.InputBox(Resource1.MinimalFilter); selectBars += FilterByAvg; break; default: input = ""; selectBars = null; break; } if (selectBars != null) { IEnumerable <Bar> iBar = selectBars(bars, input); if (iBar == null) { return(null); } List <Bar> newBarList = new List <Bar>(); foreach (Bar bar in iBar) { newBarList.Add(bar); } return(newBarList); } else { return(null); } }