"non-static method cannot be referenced from a static context"

help! i’m trying to reference a method in another class from my main class but it seems to be saying my main class is static. i don’t think it is? i’m confused

Hey @SarahBogel welcome to the forums!

Can you please provide a link to the repl?

2 Likes

In C# and Java you can’t access a non-static method without creating an instance of the class.

class Test {
    public void Func() {}
}

:white_check_mark:

public static void main() {
    Test instance = new Test();

    instance.Func();
}

:x:

public static void main() {
    Test.Func();
}

(If Func is marked static then this is reversed)

1 Like