For example, I have a list of excel cells
List<Cell> cells = new List<Cell>
{
new Cell("4"),
new Cell("Hez"),
new Cell("Method"),
new Cell("4"),
new Cell("Val"),
new Cell("Method"),
}
I need to get the only unique cell (in this case Cell("Val"), Cell("Hez")) so Distinct() is not for me.
I found this solution but it doesn't return any data at all
var uniqueTest = allData.GroupBy(cell => cell)
.Where(group => group.ToString().Count() == 1)
.Select(group => group.Key);
I think the problem is Cell object doesn't contain any comparison methods (This is IronXl lib) so this is why I'm using ToString() here.
But I don't quite understand linq yet, so any explanation or advice is appreciated
Remarks:
I need to get a list of cells back, but with unique values