38 lines
725 B
C#
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}");
|
|
}
|
|
} |