Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 43bf781b authored by Michael KRISPER's avatar Michael KRISPER
Browse files

added Extension Method Select() (without parameters) and Zip

parent 2aad36ae
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,10 @@ namespace TUGraz.VectoCommon.Utils
{
public static class EnumerableExtensionMethods
{
public static IEnumerable<(T value, int index)> Select<T>(this IEnumerable<T> self) =>
self.Select((value, index) => (value, index));
public static IEnumerable<double> ToDouble(this IEnumerable<string> self, double? defaultValue = null)
{
return self.Select(s => s.ToDouble(defaultValue));
......@@ -94,6 +98,14 @@ namespace TUGraz.VectoCommon.Utils
}
}
/// <summary>
/// Zips all elements of two enumerable together. If the enumerables dont have the same length an exception is thrown.
/// </summary>
/// <exception cref="System.InvalidOperationException">Enumeration already finished. Thrown if the enumerables dont have the same length.</exception>
public static IEnumerable<(T1 firstEnumerable, T2 secondEnumerable)> Zip<T1,T2>(this IEnumerable<T1> self, IEnumerable<T2> other) =>
self.ZipAll(other, (arg1, arg2) => (arg1,arg2));
/// <summary>
/// Sums up the values of selector.
/// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment