How to access functions in another class in the same namespace?
Hey dudes. I come from a background of Pascal and Lua, so bear with me if this is an obvious question.
I've got a big class, and I want to move some of my functions into another one to keep things tidy. But it appears to not be as simple as just making another class in the same namespace, and calling the function from there. That throws the error:
An object reference is required for the non-static field, method, or property 'Util.CanMarry(Hero, Hero)'
So what's the approach to adding functions that are called by another class?
Pic 1: The new helper class with a function in it
Pic 2: The big class that I want to use that helper function inside
Pic 3: The error



4 Replies
Well,
CanMarry
is not a static function
So it needs an instance of the class
Since it seems that it's just a pure utility function, you could probably just make both the class and the method static
That will let you use it with just Util.CanMarry(...)
Oh heck it was that simple huh. Yeah it's just going to be a class to put logic checks in.
Awesome thanks for that
:Ok:
🙁