How to check if IEnumerable is null or empty?

前端 未结 22 1026
梦如初夏
梦如初夏 2020-11-27 12:33

I love string.IsNullOrEmpty method. I\'d love to have something that would allow the same functionality for IEnumerable. Is there such? Maybe some collection he

22条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 13:16

     public static bool AnyNotNull(this IEnumerable source)
        {
            return source != null && source.Any();
        }
    

    my own extension method to check Not null and Any

提交回复
热议问题