I have created folders in my project named Classes, Forms, and Models.
Let’s say my project is named ABC, so the folder hierarchy is:
ABC
Classes
Forms
Models
In \Models\, I have a class named ApplicationModel.cs, which contains a public method named GetApplications().
However, when I call that method from elsewhere in the same ABC project, I get, “The name ‘GetApplications’ does not exist in the current context”
I’ve added:
using ABC.Models;
to the calling class, but it makes no difference. I right-clicked GetApplications() to hopefully see “Resolve” there, but no go.
What must I do to access my own public method?
It would be helpful to see the definition of
GetApplications()and the code that’s attempting to call it, but I assume it’s either a static or an instance method of theApplicationModelclass. In either case, you may have made your code aware of the namespace of theApplicationModelclass with the using statement, but the method must either be called on the class or an instance of the class, like so:If
GetApplicationsis a static method,If it’s an instance method:
One way or another, you must refer to the class containing
GetApplicationsin order to call it. If this doesn’t help you solve the problem, please edit your question to contain the definition of the method, and the calling code.