Lecture overview -- Keyboard shortcut: 'u'  Previous page: Constructors and initialization order: Example -- Keyboard shortcut: 'p'  Next page: Inheritance of methods, properties, and indexers -- 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 27 : 40
Object-oriented Programming in C#
Specialization, Extension, and Inheritance
Visibility modifiers in C#

The visibility of types in assemblies and members in classes are controlled by visibility modifiers

  • Visibility of a type (e.g. a class) in an assembly

    • internal: The type is not visible from outside the assembly

    • public: The type is visible outside the assembly

  • Visibility of members in type (e.g., methods in classes)

    • private: Accessible only in the containing type

    • protected: Accessible in the containing type and in subtypes

    • internal: Accessible in the assembly

    • protected internal: Accessible in the assembly and in the containing type and its subtypes

    • public: Accessible whenever the enclosing type is accessible

 

Go to exercisePrivate Visibility and inheritance
Go to exerciseInternal Visibility