I'm working on a project for school (going for my BA in CIS) and I've come across this issue with a class function.
public static int GetNumberCreated()
{
// return the total number of airplanes created using the class as the blueprint
return numberCreated; // returns the number of airplanes created
}//end of public int GetNumberCreated()
It's for a program to return the value of how many airplanes you've made thus far in this small C# program. I declared numberCreated at the beginning:
private int numberCreated;
I get the classic error "An object reference is required for the non-static field, method, or property" I've done a decent amount of research trying to figure out what is going on but i've come up with nothing.
I did however set a property at the bottom of the class so that a form would be able to access the variable:
public int NumberCreated { get; set; }
I also attempted changing the property to this:
public int NumberCreated { get { return numberCreated; } set { numberCreated = value; } }
with no luck. >.>'
What am i doing wrong?