0

I have added a list in my model like so:

    public static List<string> Fields
    {
        get
        {
           var results = new List<string>() { "Name", "Date", "Address", "..." };
            return results;

        }
    }

When I try to access my list in my method I get the following error: "Memeber 'Model.Fields' cannot be accessed with an instance reference; quailfy it with a type name instead"

  • 5
    Does this answer your question? [Member '' cannot be accessed with an instance reference](https://stackoverflow.com/questions/1100009/member-method-cannot-be-accessed-with-an-instance-reference) – Rogerson Nazário May 26 '20 at 12:28

1 Answers1

2

because Fields is static, if you do something like this:

MyClass test = new MyClass();

you don't access Fields using test, instead you use the class name - MyClass:

//wrong
test.Fields

//right
MyClass.Fields
Efraim Newman
  • 927
  • 6
  • 21