Lecture overview -- Keyboard shortcut: 'u'  Previous page: Class Methods -- Keyboard shortcut: 'p'  Next page: Constant and readonly variables -- 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 17 : 29
Object-oriented Programming in C#
Classes and Objects
Static Classes and Partial Classes in C#

If you have a class with only class variables and class methods (only static members), you may chose to mark the class as static. A partial class will be aggregated by contributions from several source files.

A static class C can only have static members

A partial class is defined in two or more source files

  • Static class

    • Serves as a module rather than a class

    • Prevents instantiation, subclassing, instance members, and use as a type.

    • Examples: System.Math, System.IO.File, and System.IO.Directory

  • Partial class

    • Usage: To combine manually authored and automatically generated class parts.

 

Read more about static classes and partial classes in the text book version of this material.