Is there any way I can search List<T>
and remove empty items?
ObservableCollection ListOfTnAGroupAccs <Model>
foreach (var item in ListOfTnAGroupAccs)
{
if(item.Prefix == "" && item.ReportingGrp == "" && item.AccMngInitials == "" && item.Description == "")
{
ListOfTnAGroupAccs.Remove(item);
continue;
}
}
it gives me "Collection was modified; enumeration operation may not execute"
I can use this
var nList = ListOfTnAGroupAccs.Where(l => l.Prefix != "" && l.ReportingGrp != "" && l.AccMngInitials != "" && l.Description != "").ToList();
But my curiosity is there any better way to do it?