You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: Add IsEmpty property to collections and arrays. #79769
For performance reason using LINQ ".Any()" to check if a collection is empty is discouraged in favour of checking if Length and Count is greater than zero. However arguably using "Any()" expresses the intent more clearer and there could even be collection implementations where computing Count is more expensive than just checking if the collection is empty or not.
Adding an IsEmpty property would not only solve that issue but also align with other APIs that have an IsEmpty property like Span.
API Proposal
Since there are probably millions of existing implementations of collection types, using a default implementation that checks the Count might be the best option.
Activity
eiriktsarpalis commentedon Dec 19, 2022
We generally avoid adding DIMs to existing interfaces because it can result in both source and binary breaking changes, cf. #55106.