Example #1
0
        public static void Inheritance()
        {
            Console.WriteLine("\nINHERITANCE - A student class:");

            string name2 = "Bob";
            Student bob = new Student(name2, Gender.MALE, "Physics");
            bob.AgeAFewYears(18);
            bob.Party();
            Console.WriteLine(name2 + " is a: " + Person.DisplayGender(bob.gender));
            Console.WriteLine(name2 + " studies: " + bob.Subject);

            // Must always clear up memory allocated on the heap
            bob = null;
        }
Example #2
0
        public static void SerializeDemo()
        {
            Console.WriteLine("\nSERIALIZING AN OBJECT");

            // Get input from the user
            Console.WriteLine("What is the student's name?");
            string name = Console.ReadLine();

            // Create instance
            Student stud;                                       // allocate the reference
            stud = new Student(name, Gender.MALE, "CompSci");   // allocate the object    
            // PersonsNamespace.Person man = new PersonsNamespace.Person();
            stud.Greet();
            stud.AgeAFewYears(10);

            Serializer.serialize(stud);
        }