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