31 lines
899 B
C#
31 lines
899 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Sarand.Net.Standard.Base.Utils
|
|
{
|
|
//=======================================================================
|
|
public static class EnumerableUtil
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// F o r E a c h
|
|
//-------------------------------------------------------------------
|
|
public static void ForEach<T> (this IEnumerable<T> source, Action<T> action)
|
|
{
|
|
foreach (var item in source)
|
|
action(item);
|
|
}
|
|
public static void ForEachOrBreak<T> (this IEnumerable<T> source, Func<T, bool> func)
|
|
{
|
|
foreach (var item in source)
|
|
{
|
|
bool result = func(item);
|
|
if (result) break;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|