static async Task Main(string[] args) { Adam adam = Adam.GetInstance(); Adam anotherAdam = Adam.GetInstance(); Console.WriteLine(adam is Adam); Console.WriteLine(ReferenceEquals(adam, anotherAdam)); Console.ReadKey(); }
public static Eve GetInstance(Adam adam) { if (adam is null) { throw new ArgumentNullException("Eve is created from the rib of Adam"); } else { return(_eve ?? (_eve = new Eve())); } }
public static Adam GetInstance() => _adam ?? (_adam = new Adam());