Uebungsaufgaben/Semester3/DotNET/Aufgabenblatt4/Aufgabe10/Program.cs
2024-12-19 23:55:07 +01:00

38 lines
725 B
C#

Console.WriteLine("Willkommen zu Aufgabe10");
Person person1 = new Person();
person1.FirstName = "Donna";
person1.LastName = "Summer";
public class Person
{
private string _firstName;
public string FirstName
{
get => _firstName;
set
{
_firstName = value;
NameChanged?.Invoke(value);
}
}
private string _lastName;
public string LastName
{
get => _lastName;
set
{
_lastName = value;
NameChanged?.Invoke(value);
}
}
public event Action<string> NameChanged;
public Person()
{
NameChanged += (string name) => Console.WriteLine($"Geändert: {name}");
}
}