//Step 3: Create a static method for that class and assign the object to the declared static variable. public static Toyota GetInstance() { if (obj == null) { obj = new Toyota(); } return(obj); }
static void Main(string[] args) { Toyota toyota1 = Toyota.GetInstance(); Toyota toyota2 = Toyota.GetInstance(); toyota1.ManiFacturingPlantName = "Japan"; string toyota2plantName = toyota2.getDetails(); Console.WriteLine(toyota2plantName); //Compare if two instances are equal Console.WriteLine(toyota1.Equals(toyota2)); // True Console.ReadKey(); }