0

I have this simple static class which is used so that I can access my AVLTree from everywhere in my application. For some reason however I am unable to call the variable from another class. Whenever I type Database. I only get two methods which are not what I want. I would like to access Database.countries however it is impossible.

static class Database
{
   static AVLTree<Country> countries = new AVLTree<Country>();

   static Database()
   {
   }

   static AVLTree<Country> cees()
   {
      return countries;
   }

   static AVLTree<Country> Countries
   {
      get { return countries; }
   }
}
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184
user2839999
  • 99
  • 2
  • 9
  • Your properties should be `public` if you want to access them from outside the class. – Blorgbeard Apr 07 '15 at 20:25
  • The default modifier for class members is `private` so you need to add `public` e.g. `public static AVLTree Countries`. – Lee Apr 07 '15 at 20:25

1 Answers1

3

You need to make your property public

public static class Database
{
    static AVLTree<Country> countries = new AVLTree<Country>();

    static Database()
    {

    }

    static AVLTree<Country> cees()
    {
        return countries;
    }

    public static AVLTree<Country> Countries
    {
        get { return countries; }
    }
}
Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154