C#: Add extractor support for list- and slice patterns.

This commit is contained in:
Michael Nebel
2022-12-07 16:26:28 +01:00
parent 00354a2f08
commit cfd3c1fcbe
4 changed files with 51 additions and 0 deletions

View File

@@ -79,6 +79,19 @@ namespace Semmle.Util
a(item);
}
/// <summary>
/// Applies the action <paramref name="a"/> to each item and its index in this collection.
/// </summary>
public static void ForEach<T>(this IEnumerable<T> items, Action<T, int> a)
{
var i = 0;
foreach (var item in items)
{
a(item, i);
i++;
}
}
/// <summary>
/// Forces enumeration of this collection and discards the result.
/// </summary>