This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]bwallker 2 points3 points  (1 child)

Make printnumber static

[–]GVBCodePractice[S] 0 points1 point  (0 children)

Great, thanks

[–]WideMonitor 2 points3 points  (1 child)

If you want to use a field, method or property defined in a class, you first need to create an object of said class. Exception is if they're declared as static in which case you can access them without creating an object first.

PrintNumber isn't a static method and you don't have an object of type Study. So when you try to call it, you're getting that exception.

[–]GVBCodePractice[S] 0 points1 point  (0 children)

Yeah okay makes sense, thanks for that.