In this lesson we will continue our discussion on C# Obects and Classes. In this lesson we will discuss access modifiers related to classes and object in C#.
In C#, we have the following modifiers available:
- public: same as C++
internal: internal is accessible only to types within the same assembly which is similar to package in Java.
- protected: same as C++
- internal protected: protected within the same assembly
- private: same as C++
- new: The 'new' keyword can be used for 'nested' classes. A nested class is one that is defined in the body of another class; it is in most ways identical to a class
defined in the normal way, but its access level cannot be more liberal than that of the class in which it is defined. Classes are usually specified independently of each other. But it is possible
for one class to be specified within another's specification. In this case, the later class is termed as a nested class. A nested class should be declared using the 'new' keyword just in case it
has the same name as (and thus overrides) an inherited type.
- abstract: A class declared as 'abstract' cannot itself be instanced - it is designed only to be a base class for inheritance.
- sealed: A class declared as 'sealed' cannot be inherited from. It may be noted that structs can also not be inherited from.
Next >>> Lesson No. 16: C# Methods