public static void MainCaller() { try { car mynewcar = car.carspecs(); Console.WriteLine(mynewcar.model + mynewcar.yearmake); } catch (Exception ex) { Console.WriteLine(ex); } // Both the two variables are essentially refering to same instance. try { car mydreamcar = car.carspecs(); Console.WriteLine(mydreamcar.model + mydreamcar.yearmake); } catch (Exception ex) { Console.WriteLine(ex); } }
public static car carspecs() { _instance = new car(); // This is the only instance of the class that will be available. return(_instance); }