Classes and Objects
- slide 16 : 29
Class Methods
A
class method
is associated with the class itself, as opposed to an object of the class
A class method
M
in a class
C
is declared by use of the
static
modifier in C#
can only access static members of the class
must be activated on the class as such
is activated as
C.M(...)
from outside
C
can also be activated as
M(...)
from inside C
A BankAccount class with static methods.
A client BankAccount.
Output from the BankAccount client program.
A typical problem: A class method that accesses instance variables.