Unterricht Tag 5

This commit is contained in:
wbs
2026-08-14 12:25:10 +02:00
parent 10334c1bc7
commit 7f5c7e7e47
31 changed files with 1661 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
namespace Tag_5_Unterricht;
public class Delegate
{
delegate int MathOperation(int a, int b);
delegate void SendEvent(string message);
public static void Main()
{
Console.WriteLine("Delegate:");
Func<int, int, int> add = (a,b) => a + b;
MathOperation add2 = (a, b) => a + b;
Console.WriteLine(add2(1, 4));
SendEvent sendEvent;
sendEvent = m => Console.WriteLine("Msg: " + m);
sendEvent = (m => Console.WriteLine("New Message!")) + sendEvent;
sendEvent("Hello World");
sendEvent("Hallo Welt");
var mOp = new MathOperation(add);
mOp = new MathOperation((a, b) => a * b);
Console.WriteLine(mOp(2, 5));
}
}