Removing elements of a list of class having some specific duplicate properties
I'll try to explain with a example C# code-
There's a List<A> where A is a class
Class A
{
 Int Id{get; set;}
 String name{ get; set;}
 B b{get; set;} // B is a Class
}
Class B
{
 Int sId{get; set;}
 String detail{get; set;}
}
Now List<A> contains a list of elements. I have to remove those specific duplicates from this list whose Id and sId have been there in the list once.
So its just a Removal of duplicates from a list but wrt these two properties.
Any help in this would be appreciated
Adding more details for better explanation
Consider this Json data representing my above Code-
A{
   Id: 1
   Name:  Harry
   b
    { 
      sId: 1
      detail: Book
     },
    Id: 2
   Name:  Harry
   b
    { 
      sId: 2
      detail: Book
     }
     Id: 1
   Name:  Russel
   b
    { 
      sId: 1
      detail: Biography
     }
Output which I want-
A{
   Id: 1
   Name:  Harry
   b
    { 
      sId: 1
      detail: Book
     },
    Id: 2
   Name:  Harry
   b
    { 
      sId: 2
      detail: Book
    }
Also would like to tell that this basic approach is working fine-
int a;
int b;
for (int i = 0; i < A.Count; i++)
{
a = A[i].Id;
b = A[i].b.sId;
for (int j = i + 1; j < (A.Count-1); j++)
{
if ((A[j].Id == a) && (A[j].b.sId == b))
{
A.RemoveAt(j);
}
}
}
But It would be great to have a better approach to do this. Maybe a Linq or other
Would need help on that... Thank You
 
    