I have a List<NameClass> that stores a collection of NameClass elements with a property called Name in the class. What I'm trying to do is write a Linq query that will pull out all the names starting with Jones , but only if there are 3 or more cases. For example, if my list had the following items:
Name ----------- Jones Jonestown Smith Hector Jones Smith Smith
I am looking for a C # function that I can call as follows:
GetNames("Jones");
And he must return:
Jones Jonestown Jones
And if I run this:
GetNames("Smith");
He must return:
Smith Smith Smith
And if I run this:
GetNames("Hector");
It should not return anything, since the Hector not in the list 3 or more times.
Any help in writing this LINQ query would be appreciated!
source share