c# - LINQ optimization using single query on collection of integers -
i have list of integers below
list<int> mycollection = new list<int> { 2625 };
i checking below condition
if(mycollection.count() == 1 && mycollection.any(number=> number == 2625)) { // }
how can optimize query can include both conditions single query? note: mycollection may contain multiple elements hence have used any().
one obvious optimization use list
instance properties:
if(mycollection.count == 1 && mycollection[0] == 2625)) { // }
Comments
Post a Comment