public static Sun GetInstance() { if (_instance == null) { lock (locker) { _instance = new Sun(); } } return(_instance); }
public static void MainProgram() { var sun = Sun.GetInstance(); var newSun = Sun.GetInstance(); if (sun == newSun) { Console.WriteLine("Shit, we have two similar suns!"); } var moon = Moon.GetInstance(); var newMoon = Moon.GetInstance(); if (moon == newMoon) { Console.WriteLine("Shit, we have two similar moons! Their radius is {0}", Moon.GetInstance().Size); } }