This should be quite easy, however I am failing to see why all my methods are not working.
I have looked at all the solutions and used them appropriately however am not getting the result.
Here is the code:
IEnumerable<feature> available = _repo.GetAvailableFeatures();
IEnumerable<feature> selected = _repo.GetSelectedFeatures();
var filteredList = (available.Except(selected)).ToList;
var availableList = available.ToList();
var selectedList = selected.ToList();
availableList.RemoveAll(item => selectedList.Contains(item));
for (var i = 0; i < availableList.Count - 1; i++)
foreach (var t in selectedList)
if (availableList[i].Id == t.Id)
public class Feature
public int Id;
public int Desc;
When you use
Except you need to define what "equal" means for the
feature type. In your loop you define "equal" as "
Ids are equal", so you could:
Where instead of
var filteredList = available.Where(a => !selected.Any(s => s.Id == a.Id)) .ToList();