I have a static method [Method1] in my class, which calls another method [Method2] in the same class and is not a static method. But this is a no-no. I get this error:
You need an instance of the class class to call the non-static method. You could create an instance of ClassName and call Method2 like so:
public class ClassName
{
public static void Method1()
{
ClassName c = new ClassName();
c.Method2();
}
public void Method2()
{
//dostuff
}
}
The static keyword basically marks a method as being call-able by referencing only its type [ClassName]. All non-static methods have to be referenced via an instance of the object.