I am trying to compare 2 collection with lists of strings. 1st object with list of strings:
a0, b0, c0
a1, b1, c0
a1, b2, c0
a1, b2, c1
2nd
a0, b0, c0
a1, b2, c0
I have method go get list of string from object
public List<string> GetPlainRow(int index)
{
if(index >= _countRows || index < 0)
{
throw new IndexOutOfRangeException();
}
List<string> returnedRow = new List<string>();
foreach (KeyValuePair<string, List<string>> entry in _dataRows)
{
returnedRow.Add(entry.Value[index]);
}
return returnedRow;
}
Tried to compare objects lists with:
for (int i = 0; i < dataCollection.CountRows; i++)
{
var newRow = table.NewRow();
for (var j = 0; j < dataCollection.GetPlainRow(i).Count; j++)
{
newRow[j] = dataCollection.GetPlainRow(i)[j];
}
for (int k = 0; k < dataCollection.CountRows; k++)
{
for (int l = 0; l < dataRestrained.CountRows; l++)
{
if(dataCollection.GetPlainRow(k).SequenceEqual(dataRestrained.GetPlainRow(l)))
{
found = true;
}
}
}
newRow[dataCollection.CountRows - 2] = found;
found = false;
table.Rows.Add(newRow);
}
But it seems like everytime its returning true, but when i've used Equals instead of SequenceEqual it was returning false.
>` variables described above, what is the output?
– Tom Faltesek Nov 05 '19 at 18:43