Eisbrecher¶

Willkommen zu unserem spielerischen Icebreaker! Heute machen wir eine kleine Runde zum Thema Programmierung in C#. Keine Sorge, es geht nicht um eine PrĂĽfung, sondern um SpaĂź und gemeinsames Lernen.
So funktioniert’s:
- Ich werde euch gleich nach und nach Code-Konzepte aus der C#-Welt vorlesen, die immer komplexer werden. Steht bitte alle mal auf.
- Wenn du das vorgelesene Konzept nicht kennst, setzt du dich hin. (Kein Schummeln – Ehrlichkeit ist hier der Schlüssel!)
- Aus der Gruppe derer, die noch sitzen, wählt jemand eine Person aus, die kurz und verständlich erklärt, was das Konzept bedeutet.
Das Ziel: Gemeinsam lernen und Spaß haben! Am Ende sollten alle zumindest eine Idee von dem gemeinsamen Wissen unter uns haben. Und es ist absolut in Ordnung, wenn man aufsteht – das zeigt, dass man noch viel Spannendes zu entdecken hat!
Los geht's!
Hier ist eine Liste von C#-Codezeilen, die immer komplexer werden:
Einfache Ausgabe:
Console.WriteLine("Hallo, Welt!");
Einfache Arithmetik:
int sum = 5 + 3;
Boolesche Algebra:
bool isTrue = (5 > 3) && (2 < 4);
Statische Klasse:
public static class MathHelper { public static int Add(int a, int b) => a + b; }
Nicht-statische Klasse:
public class Person { public string Name { get; set; } public int Age { get; set; } public void Greet() { Console.WriteLine($"Hallo, mein Name ist {Name}."); } }
Event:
public class Alarm { public event Action OnAlarmRaised; public void RaiseAlarm() { OnAlarmRaised?.Invoke(); } }
Delegat:
public delegate void Notify(string message); public class Notifier { public Notify Notification { get; set; } public void SendNotification(string msg) { Notification?.Invoke(msg); } }
Async/Await:
public async Task<string> FetchDataAsync() { await Task.Delay(1000); return "Daten geladen"; }
Lambda-Ausdruck:
Func<int, int, int> multiply = (x, y) => x * y;
MVVM Pattern (Model-View-ViewModel) mit Mermaid-Diagramm und Sample Code:
Mermaid-Diagramm:
graph TD; View --> ViewModel; ViewModel --> Model; Model --> ViewModel; ViewModel --> View;
Beispielcode:
// Model
public class PersonModel
{
public string Name { get; set; }
public int Age { get; set; }
}
// ViewModel
public class PersonViewModel : INotifyPropertyChanged
{
private PersonModel _person;
public string Name
{
get => _person.Name;
set
{
_person.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public PersonViewModel()
{
_person = new PersonModel { Name = "John Doe", Age = 30 };
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
// View (XAML)
/*
<Window x:Class="MVVMExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox Text="{Binding Name}" />
</Grid>
</Window>
*/