Uebungsaufgaben/Semester3/DotNET/Aufgabenblatt4/Aufgabe10/Program.cs

38 lines
725 B
C#
Raw Permalink Normal View History

2024-12-19 22:55:07 +00:00
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}");
}
}