public static void Main()
Person thisIsMe = new Person("Matthias");
thisIsMe.Birthday = new DateTime(1983, 6, 3);
Console.WriteLine(thisIsMe.AgeInfo());
Console.WriteLine(thisIsMe.BirthdayMonthInfo());
Console.WriteLine(thisIsMe.charInsideName('t'));
Person thisIsMyBaby = new Person("Baby");
thisIsMyBaby.Birthday = new DateTime(2019, 6, 3);
Console.WriteLine(thisIsMyBaby.AgeInfo());
Console.WriteLine(thisIsMyBaby.BirthdayMonthInfo());
delegate string CalcAge(DateTime ReportingDate, DateTime Birthday);
public Person(string NameOfPerson)
public DateTime Birthday;
if (this.Birthday > DateTime.Now)
method = CalcAgeOfUnbornPerson;
bool personUnborn = true;
method = CalcAgeOfPerson;
string age = method(DateTime.Now, this.Birthday);
public string BirthdayMonthInfo()
case 2: return "Februar";
case 9: return "September";
case 10: return "Oktober";
case 11: return "November";
case 12: return "Dezember";
default: return String.Empty;
private string CalcAgeOfPerson(DateTime ReportingDate, DateTime Birthday)
int age = ReportingDate.Year - Birthday.Year;
return this.Name + " ist " + age + " Jahre alt" ;
private string CalcAgeOfUnbornPerson(DateTime ReportingDate, DateTime Birthday)
int age = (int)(Birthday - ReportingDate).TotalDays;
return this.Name + " wird in " + age + " Tagen geboren";
public int charInsideName(char search)
while (counter < Name.Length)
if (Name[counter].Equals(search))
throw new NotSupportedException();