none
List linq question? RRS feed

  • Question

  • Linq is great at finding things in a list, but if you're looking for dups. in a list can you set how many?? lets say I have num as my value and I have a list to search threw is it possable to check the amount of times( greater than or less than) that num is in the list, bool expression is all thats needed? How do go about that?

    thanks

    Saturday, January 26, 2013 11:36 PM

Answers

  • Wouldn't that just be checking whether the count of the value is greater or less than your value?

    List<int> ints = new List<int> { 1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9 };
    
    bool res = ints.Count(i => i == 1) > 3;

    • Marked as answer by superlurker Sunday, January 27, 2013 4:53 AM
    Sunday, January 27, 2013 2:10 AM

All replies