Reputation: 1
I have datatable like this:
Code Class
A Math
A History
B Math
B Math
I wanna rows which have same Code value but Class is not same. Something Expected:
A math
A History
I had tried Datatable.select and Group By , but it Dont work! Help me.
Upvotes: 0
Views: 53
Reputation: 2857
Simplest way of doing this via LINQ should be something like:
dataTable.Distinct()
.GroupBy(x => x.Code)
.Where(gr => gr.Count() > 1)
.SelectMany(gr=> gr);
Upvotes: 1