- In the Chapter1 class, create a new method called OutputInformation() that takes a person object as parameter.
public void OutputInformation(object person) { }
- Inside this method, we would need to check what type of object is passed to it. Traditionally, we would need to do the following:
if (person is Student) { Student student = (Student)person; WriteLine($"Student {student.Name} {student.LastName} is enrolled for courses {String.Join<int>( ", ", student.CourseCodes)}"); } if (person is Professor) { Professor prof = (Professor)person; WriteLine($"Professor {prof.Name} {prof.LastName} teaches {String.Join<string>(",", prof.TeachesSubjects)}"); }
- We have two if statements. We are expecting either a Student object ...