static void Main(string[] args) { PersonC classPerson = new PersonC(30, "Hugo"); PersonS structPerson = new PersonS(30, "Anna"); Console.WriteLine($"{classPerson.Name}: {classPerson.Alter}"); Console.WriteLine($"{structPerson.Name}: {structPerson.Alter}"); Altern(classPerson); Altern(structPerson); Console.WriteLine($"{classPerson.Name}: {classPerson.Alter}"); Console.WriteLine($"{structPerson.Name}: {structPerson.Alter}"); Altern(ref structPerson); Console.WriteLine($"{structPerson.Name}: {structPerson.Alter}"); }
public static void Altern(PersonC person) { person.Alter++; }