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

Popular posts from this blog

php - Hide output during test execution -

javascript - Migrate custom AngularJS filter from 1.2.28 to 1.4.x -

Update Magento products with multiple images -