59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Plane.Collections
|
|||
|
{
|
|||
|
public static class EnumerableExtensions
|
|||
|
{
|
|||
|
public static void ForEach<T>(this IEnumerable items, Action<T> action)
|
|||
|
{
|
|||
|
if (items == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(items));
|
|||
|
}
|
|||
|
if (action == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(action));
|
|||
|
}
|
|||
|
foreach (T item in items)
|
|||
|
{
|
|||
|
action(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
|
|||
|
{
|
|||
|
if (items == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(items));
|
|||
|
}
|
|||
|
if (action == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(action));
|
|||
|
}
|
|||
|
foreach (var item in items)
|
|||
|
{
|
|||
|
action(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static string JoinToString(this IEnumerable<string> items, string separator)
|
|||
|
{
|
|||
|
if (items == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(items));
|
|||
|
}
|
|||
|
return string.Join(separator, items);
|
|||
|
}
|
|||
|
|
|||
|
public static string JoinToString<T>(this IEnumerable<T> items, string separator)
|
|||
|
{
|
|||
|
if (items == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(items));
|
|||
|
}
|
|||
|
return string.Join(separator, items);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|