Files
Common-VS2019/SacsStandardBase/Base/Utils/EnumerableUtil.cs
T
2021-05-05 15:36:28 +01:00

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;
}
}
//-------------------------------------------------------------------
}
//=======================================================================
}