How to convert below c# nested for loop to linq...?
list = objBLForms.GetForms(Ids);
for (int i = 0; i < list.Count; i++)
{
for (int j = 0; j < list.Count; j++)
{
if (list[i].StateId == list[j].StateId &&
list[i].PayerId == list[j].PayerId && i != j)
{
if (string.IsNullOrEmpty(list[i].Tax))
{
list.Remove(list[i]);
}
else
{
list.Remove(list[j]);
}
}
}
}
I want to Remove duplicate payers with same state..And if any state tax is present, i wanted to remove the other duplicate one i,e; the duplicate one which is having no state tax... I have achived it by using the nested for loop as shown above. is there any way to do it in linq..I dont't know anything about linq. Am very new to linq,Thanks in advance
&& i != jisn't needed: just startjat 1 rather than 0.Count. You are bound to compare an object to its own self