Listing A



using System;
 //System is used because we want to use the Console.WriteLine() method.
 namespace MyProgram
 {
 class Automobile
 {
 public static void Main()
 {
 // Create Sample Objects:
 Automobile MyCar = new Automobile();
 Automobile YourCar = new Automobile();
 // Equals() method:
 Console.WriteLine("MyCar is equivalent to YourCar:\t" + MyCar.Equals(YourCar));
 // GetHashCode() method:
 Console.WriteLine("MyCars Hash Code is:\t" + MyCar.GetHashCode());
 // GetType() method:
 Console.WriteLine("The class type for MyCar is:\t" + MyCar.GetType());
 // ToString() method:
 Console.WriteLine("All I have to say is: \t" + MyCar.ToString());
 } } }


You can save this code as "myfile.cs" and compile it from the command line by using the command "csc.exe myfile.cs"
and run the resulting .exe file to get the following output:

MyCar is equivalent to YourCar: False MyCars Hash Code is: 3 The class type for MyCar is: MyProgram.Automobile All I have to say is: MyProgram.Automobile