1234567891011121314151617181920212223242526272829303132333435363738 |
- namespace IES.ExamServer.Helpers
- {
- public static class CollectionHelper
- {
- /// <summary>
- /// 判断集合是否为空
- /// </summary>
- /// <param name="collection"></param>
- /// <returns></returns>
- public static bool IsEmpty<T>(this IEnumerable<T>? collection)
- {
- if (collection != null && collection.Any())
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- /// <summary>
- /// 判断集合是否不为空
- /// </summary>
- /// <param name="collection"></param>
- /// <returns></returns>
- public static bool IsNotEmpty<T>(this IEnumerable<T>? collection)
- {
- if (collection != null && collection.Any())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
|