I have a List<List<string>> in C# - the number of items in the parent list will vary - there could be 1 or there could be 5. I need to know if there are any duplicates when considering all values in the same position in all lists.
This is vary similar to a database unique constraint on a composite key where you cant have duplicates. Each List contains all of the values from the data in the table.
For example if I have the following structure (but each one can have just 1 column or more):
Product Color Size
Tshirt Blue S
Tshirt Blue M
Tshirt Blue L
Tshirt Blue S <-- this is a duplicate
Tshirt Red S
This would be
var items = new List<List<string>>()
{
new List<string>() { "Tshirt", "Tshirt", "Tshirt", "Tshirt", "Tshirt", },
new List<string>() { "Blue", "Blue", "Blue", "Blue", "Red", },
new List<string>() { "S", "M", "L", "S", "S", },
};
And I would need to detect the fact that there are duplicates and print the duplicates as
Duplicate: Tshirt, Blue, S
Note: finding a duplicate in a single list as addressed in the referenced 'duplicate' is easy, and finding duplicates if the list is static is tackleable, but this is different in that the size is completely unknown. It could really be a List<List<string>> that has 0 elements, 1 or more.


List<List<string>>? That is just bizarre and makes what you want to do more difficult.