Commit 47defdf4 authored by Uwe Wienkop's avatar Uwe Wienkop
Browse files

2020-06-16a

parent 9dea08d0
using System;
using System.Collections.Generic;
namespace _08_DelegateAnwendungen
{
......@@ -9,14 +10,30 @@ namespace _08_DelegateAnwendungen
static T[] ApplyAll<T>(MeineFkt<T> fkt, params T[] werte)
{
T[] erg = new T[werte.Length];
Console.Write("APPLY ALL: ");
for (int i = 0; i < werte.Length; i++)
{
erg[i] = fkt(werte[i]);
Console.Write (erg[i]); Console.Write(" ");
Console.Write ($"{erg[i]} ");
}
Console.WriteLine();
return erg;
}
static T[] Select<T>(Predicate<T> filter, params T[] werte)
{
Console.Write("SELECT: ");
List<T> erg = new List<T>();
foreach (var item in werte)
{
if (filter(item))
{
erg.Add(item);
Console.Write($"{item} ");
}
}
Console.WriteLine();
return erg.ToArray();
}
static int Quadrieren(int x) => x * x;
static void Main(string[] args)
......@@ -29,6 +46,10 @@ namespace _08_DelegateAnwendungen
string[] namen = { "Anton", "Berta", "Claudia", "Emil", "Dieter" };
ApplyAll(x => x.ToUpper(), namen);
Console.WriteLine("----------");
Select (x => x.Contains("E"), ApplyAll(x => x.ToUpper(), namen));
Console.WriteLine("----------");
Select(x => x > 100, ApplyAll(x => x * 2, 10, 30, 40, 50, 60, 70, 80, 100));
}
}
}
......@@ -10,3 +10,4 @@ C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\De
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.genruntimeconfig.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.csprojAssemblyReference.cache
......@@ -10,3 +10,4 @@ C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.genruntimeconfig.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.csprojAssemblyReference.cache
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment