Lecture overview -- Keyboard shortcut: 'u'  Previous page: Class Variables -- Keyboard shortcut: 'p'  Next page: Static Classes and Partial Classes in C# -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 16 : 29
Object-oriented Programming in C#
Classes and Objects
Class Methods

A class method is activated on a class. In contrast, an instance method is activated on an object. The Main method, which usually initiates our programs, is an example of a class method.

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

/user/normark/oop-csharp-1/sources/c-sharp/bank-account/bank-account-5/bank-account.csA BankAccount class with static methods. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/bank-account/bank-account-5/bank-account-client.csA client BankAccount.


/user/normark/oop-csharp-1/sources/c-sharp/bank-account/bank-account-5/outputOutput from the BankAccount client program.


/user/normark/oop-csharp-1/sources/c-sharp/bank-account/bank-account-1/bank-account-client.csA typical problem: A class method that accesses instance variables. This program is explained


Read more about class methods in the text book version of this material.