There are two ways to access class methods (assuming that the access specifiers permit you to, but let's assume that all the methods are
public
which means that any class can access them).
The first is a
static
access:
int result = Library.Multiply( 2, 5 );
This requires a
static
definition:
public class Library
{
private int myValue = 666;
public static int Multiply(int a, int b) { return a * b; }
}
The disadvantage of this is that the Multiply method can only access
static
members of the Library class: it cannot access class instance members. Thus, Multiply cannot access myValue.
The other is to use an instance of the Library:
Library lib = new Library();
int i = lib.Multiply( 2, 10 );
This requires an instance definition:
public class Library
{
private int myValue = 666;
public int Multiply(int a, int b) { return a * b; }
}
In this version, Multiply can access myValue if it needs to, because it has access to all the instance members of the Library class.