Example #1
0
 public static SingletonDatabase GetDatabaseInstance()
 {
     if (DbInstance == null)
     {
         DbInstance = new SingletonDatabase();
     }
     return(DbInstance);
 }
Example #2
0
        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)}");
        }