Here's what I have.
public static void Person_home_phone_TextChanged(object sender, EventArgs e) { ... }
Is there any way to access non-static methods from the same or another class from inside this static method?
I need grab the text in the Person_home_phone text box and save it to a class data member.
Solution #1: Instantiate a new instance of Car every time the method is called.
Solution #2: Pass a Car to the method.
Solution #3:
Use a singleton Car to support the static method. (If calls from multiple threads are a possibility, you might also need locking. Note that System.Windows.Forms.Timer does not introduce a thread.)
Note that you have not explained your memory problems with Timer. It is very possible that there is a solution to that underlying problem.
A non-static method requires an instance of the class. Unless you have passed in an instance, or created an instance in your method, you cannot call a non-static method, as you have no idea what instance of the class that method should operate on.
You need an instance of the class class to call the non-static method.
Instance methods (vel. non-static) can only be called in context of an instance of that class. So you can call it, but you have to have an object of that class available somewhere in your static method.
You should have an object to access its method.
statics doesn't belong to objects. They belongs to class declarations.
Example() -> Example
You would just need to create an instance of the
type
then call thenon-static
, from astatic
method.You need to have a instance of the class to call a non-static method.