static void Main(string[] args) { CollegeEmployee emp1 = new CollegeEmployee("James", "Doe", "Ajanlekoko street, Lagos", 45601, "09045673421", "345689", 5000M, "Works&Housing"); CollegeEmployee emp2 = new CollegeEmployee("David", "Vave", "Ajanlekoko street, Kaduna", 45699, "0904567889", "345009", 4500M, "Senate"); Faculty mem1 = new Faculty("Abigail", "lawson", "Chevron drive, Lekki", 45678, "09045673451", "456789", 7000M, "Building", true); Faculty mem2 = new Faculty("Abby", "law", "Chevron drive, Banana Island", 45678, "09045673451", "456789", 7000M, "Engineering", true); Student stud1 = new Student("Janet", "Han", "Lekki Penninsula, Lagos", 55555, "08034567890", "Construction Management", 3.5M); Student stud2 = new Student("Joke", "Silva", "Lekki Penninsula, Lagos", 66678, "08034567890", "Maintenance Management", 4.0M); Person[] Info = new Person[6] { emp1, emp2, mem1, mem2, stud1, stud2 }; foreach (var item in Info) { if (item is Student) { var changeDept = (Student)item; changeDept.Study = "Computer Science"; Console.WriteLine(item); } else { Console.WriteLine(item); } } }
static void Main(string[] args) { // Console.WriteLine("Hello World!"); CollegeEmployee colEmp1 = new CollegeEmployee("James", "Stuart", "Avenue B, Lane 5", "245678", "+0112456879", "456-879-10", 2000M, "Physics"); CollegeEmployee colEmp2 = new CollegeEmployee("Janet", "Wallace", "Avenue C, Lane 9", "246578", "+0252456879", "+456-879-10", 1850M, "Geography"); Faculty facEmp1 = new Faculty("Judas", "Brown", "Avenue D, Lane 7", "554488", "+245621137", "225-456-44", 2105M, "Economics", false); Faculty facEmp2 = new Faculty("Esther", "Easter", "Avenue E, Lane 8", "550088", "+195621137", "330-456-44", 2105M, "Economics", false); Student student1 = new Student("Mike", "Hanger", "Avenue F, Lane 12", "214990", "+11265422", "Yoruba", 2.31M); Student student2 = new Student("Ruth", "Hover", "Avenue G, Lane 10", "255990", "+11999422", "French", 3.67M); Person[] members = new Person[] { colEmp1, colEmp2, facEmp1, facEmp2, student1, student2 }; foreach (Person member in members) { if (member is Student) { var modStudent = (Student)member; modStudent.Field = "Computer Science"; } Console.WriteLine(member + "\n"); } // Console.WriteLine(members[4].); }
static void Main(string[] args) { CollegeEmployee emp1 = new CollegeEmployee("Davies", "Holter", "23, houston, Texas, USA", 75247, 1604326661, 5442, 75000); CollegeEmployee emp2 = new CollegeEmployee("Mitchel", "Paul", "43B, Lekki, Lagos, Nigeria", 75247, 1604326661, 5442, 75000); Faculty member = new Faculty("Micheal", "Adeponle", "17, Kajola street, ibadan, oyo", 65211, 0907543729, 44432, 23000, true); Faculty member2 = new Faculty("O'neal", "Matthew", "Tanke, ilorin", 4321, 0802316432, 5433, 4000, false); Student student = new Student("Kolapo", "Abiona", "Lagos hood town, epe, lagos", 2319, 0902874171, "Law", 3.5m); Student student2 = new Student("Badiru", "Habeeb", "Kano way, katangoa, Kano", 2542, 090225432, "Agric", 3.8m); Person[] list = new Person[] { emp1, emp2, member, member2, student, student2 }; foreach (var person in list) { if (person is Student) { var studt = (Student)person; studt.Course = "Computer Science"; Console.WriteLine(person); } else { Console.WriteLine(person); } } }