I'm a beginner with LINQ and I would like to know if it is possible to use it to solve the following problem:
I have a class :
public class myClass
{
public int Id { get; set; }
public int Category { get; set; }
public string Text { get; set; }
}
And I have a list of myClass
objects.
public List<myClass> myList;
Can I easily get with LINQ the sublist of myList
containing all the myClass
objects for which the value of the property Text
is present more than once.
for instance if I have
myClass A = new myClass { Id=1, Category=1, Text="Hello World!"};
myClass B = new myClass { Id=2, Category=2, Text="Hello World!"};
myClass C = new myClass { Id=3, Category=2, Text="Good Bye!"};
myList.AddRange(new []{ A, B, C });
I should have objects A
and B
in my sublist