Yuebon.NetCore/Yuebon.Commons/Linq/EnumerableExtentions.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace Yuebon.Commons.Linq
{
public static partial class EnumerableExtentions
{
public static T[] AsToArray<T>(this IEnumerable<T> source, bool isNullAsEmpty = false)
{
if (source == null)
{
return isNullAsEmpty ? new T[0] : null;
}
return source as T[] ?? source.ToArray();
}
public static List<T> AsToList<T>(this IEnumerable<T> source, bool isNullAsEmpty = false)
{
if (source == null)
{
return isNullAsEmpty ? new List<T>() : null;
}
return source as List<T> ?? source.ToList();
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="process"></param>
public static void ForEach<T>(this IEnumerable<T> source, Action<T> process)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
if (process == null)
{
throw new ArgumentNullException(nameof(process));
}
foreach (T item in source)
{
process(item);
}
}
public static void ForEach<T, R>(this IEnumerable<T> source, Func<T, R> process)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
if (process == null)
{
throw new ArgumentNullException(nameof(process));
}
foreach (T item in source)
{
后面还有 5 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。