public static SingletonDatabase GetDatabaseInstance() { if (DbInstance == null) { DbInstance = new SingletonDatabase(); } return(DbInstance); }
static void Main(string[] args) { SingletonDatabase db = SingletonDatabase.Instance; var city = "Tokyo"; SingletonDatabase db2 = SingletonDatabase.Instance; var city2 = "Delhi"; Console.WriteLine($"{city}: {db.GetPopulation(city)}"); Console.WriteLine($"{city2}: {db2.GetPopulation(city2)}"); }