I have a simple array of objects:
Contact[] contacts = _contactService.GetAllContacts();
I want to check if this method returns any contacts. I really like the LINQ syntax for Any() , as it emphasizes what I'm trying to achieve:
if(!contacts.Any()) return;
However, is it slower than just checking the length of the array?
if(contacts.Length == 0) return;
Is there any way to find out which Any() operation is performed in this case without having to go here? Something like Profiler, but for collections in mind?
c # linq linq-to-objects
Codingintrigue
source share