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

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -