static void Main(string[] args) { Adam adam = Adam.GetInstance(); Eve eve = Eve.GetInstance(adam); Console.WriteLine(adam.Name); Console.WriteLine(eve.Name); Console.ReadLine(); }
public static Eve GetInstance(Adam adam) { lock (locker) { if (adam == null) { throw new ArgumentNullException(); } if (uniqueInstance == null) { uniqueInstance = new Eve("Eve"); } return(uniqueInstance); } }