I apologize for the ambiguous title. I couldn't keep it clear and concise at the same time. So feel free to change it.
I have a big List which contains several other Lists. And these inner Lists contain Column objects.
List<List<Column>> listOfAllColumns;
Let's say my inner lists contain different Column objects like this:
list1 = {c1, c1, c2}
list2 = {c1, c2, c1}
list3 = {c2, c3}
list4 = {c1,c1, c2}
And the big list contains these lists: listOfAllColumns = {list1, list2, list3, list4}
Now I want a method that removes duplicate lists from the listOfAllColumns list. For example, it will look into the list above and remove list4.
list1: c1,c1,c2
list2: c1,c2,c1
list3: c2,c3
list4: c1,c1,c2 (it is equal to list1 so it is a duplicate)
Here is my code:
public class ColumnList
{
public void RemoveDuplicateColumnTypes()
{
Column c1 = new Column() { SectionName = "C50", StirrupType = "Tie" };
Column c2 = new Column() { SectionName = "C50", StirrupType = "Spiral" };
Column c3 = new Column() { SectionName = "C40", StirrupType = "Tie" };
List<Column> list1 = new List<Column>() { c1, c1, c2 };
List<Column> list2 = new List<Column>() { c1, c2, c1 };
List<Column> list3 = new List<Column>() { c2, c3 };
List<Column> list4 = new List<Column>() { c1, c1, c2 };
List<List<Column>> listOfAllColumns = new List<List<Column>>() { list1, list2, list3, list4 };
var result = listOfAllColumns.Distinct();
}
}
class Column
{
public string SectionName;
public string StirrupType;
public int StirrupSize;
public double StirrupSpacing;
}
By the way the order is important, so for example {c1, c2, c1} is different than {c2,c1,c1}.