Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IEnumerable<T>.IsNullOrEmpty() extension method #14

Closed
roman-yagodin opened this issue Feb 26, 2018 · 0 comments
Closed

Add IEnumerable<T>.IsNullOrEmpty() extension method #14

roman-yagodin opened this issue Feb 26, 2018 · 0 comments
Milestone

Comments

@roman-yagodin
Copy link
Member

roman-yagodin commented Feb 26, 2018

Basic implementation:

using System.Collections.Generic;
using System.Linq;

namespace R7.Dnn.UserHtml.Models
{
    public static class EnumerableExtensions
    {
        public static bool IsNullOrEmpty<T> (this IEnumerable<T> source) =>
           source == null || !source.Any ();
    }
}

More advanced implementation would contain ICollection<T>.Count checks for better performance. Example: http://blog.vkuznetsov.ru/posts/2011/08/31/csharp-ienumerable-isnullorempty

@roman-yagodin roman-yagodin added this to the v0.13 milestone Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant