private static void CloneExample() { var s1 = new Student(); s1.Name = "Mihai"; s1.Address = new Address(); s1.Address.Line1 = "Iasi"; var s2 = new Student(); s2.Name = "Mihai"; if (s1 == s2) { Console.WriteLine("Egalitate"); } else { Console.WriteLine("Diferite"); } var s3 = s1.Clone(); s1.Address.Line1 = "Bucuresti"; var c = 5 is object; }
static void Main(string[] args) { List <Person> people = new List <Person>(); Person mark = new Person("Mark", 46, "male"); people.Add(mark); Person jane = new Person(); people.Add(jane); Student john = new Student("John Doe", 20, "male", "BME"); Student johnTheClone = (Student)john.Clone(); people.Add(johnTheClone); people.Add(john); Student student = new Student(); people.Add(student); Mentor gandhi = new Mentor("Gandhi", 148, "male", "senior"); people.Add(gandhi); Mentor mentor = new Mentor(); people.Add(mentor); Sponsor sponsor = new Sponsor(); people.Add(sponsor); Sponsor elon = new Sponsor("Elon Musk", 46, "male", "SpaceX"); people.Add(elon); student.SkipDays(3); for (int i = 0; i < 5; i++) { elon.Hire(); } for (int i = 0; i < 3; i++) { sponsor.Hire(); } foreach (Person person in people) { person.Introduce(); person.GetGoal(); } PallidaClass badass = new PallidaClass("BADA55"); badass.AddStudent(student); badass.AddStudent(john); badass.AddMentor(mentor); badass.AddMentor(gandhi); badass.Info(); Console.ReadLine(); }