Lecture overview -- Keyboard shortcut: 'u'  Previous page: Representation Independence -- Keyboard shortcut: 'p'  Next page: Overview of members in classes -- 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 11 : 29
Object-oriented Programming in C#
Classes and Objects
Classes in C#

At this page we take a look at (a simplified version of) the syntactic composition of a class in C#.


class-modifiers class class-name{
  variable-declarations
  constructor-declarations
  method-declarations
}

The syntactic composition of a C# Class. This is not the whole story. There are other members than variables, constructors and methods. Notice also that it is NOT required that variables come before constructors and that constructors come before methods.

  • Members: Class constituents are called members

    • Variables, constructors, methods

    • Other class members will be discussed in coming lectures

  • Visibility: Members may be private or public

    • The default visibility is private

    • Do not rely on default visibility!

  • Ordering: There is no prescribed ordering among members

    • A given coding style typically recommends some particular ordering.

 

Read more about classes in C# in the text book version of this material.