Is it possible to have Collections.IsNullEmpty()/Enumerable.IsNullOrEmpty() in framework #43639
-
With current available functions to check null/ empty collections/enumerable we need to write some extension method or add explicit check on collection/enumerable for null and count ==0. Also to check empty - we can apply Any method from Linq but it throws exception null. So is it possible to have Collections.IsNullEmpty()/Enumerable.IsNullOrEmpty() in framework. Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
This would be more properly a request for new methods in the base class library, not a change to the C# language. However, given the strong push to detect null values and enable programmers to avoid having null show up unexpectedly, I'm not sure they would gain much traction. While explicit handling is required, the current solutions are pretty concise:
FWIW, I used the name |
Beta Was this translation helpful? Give feedback.
-
While it is convenient , there is much work defining how it should be implemented. |
Beta Was this translation helpful? Give feedback.
-
Good answers above in comments. Can't mark comment as answer. Marking as answered. |
Beta Was this translation helpful? Give feedback.
Good answers above in comments. Can't mark comment as answer. Marking as answered.