What is nested class
The .Net Framework allows you to define a class within another class. Such class is called a nested class. That means a class can be declared within the scope of another class and it is a member of its enclosing class.
The nested types default to private, but can be made public, protected internal, protected, internal, or private. If a class is nested in the public section of a class, it is visible outside the surrounding class. If it is nested in the protected section it is visible in derived classes, if it is nested in the private section, it is only visible for the members of the outer class.
Nested classes have access to the private members of the outer class. It is a way of logically grouping classes that are only used in one place. It increases encapsulation. Nested classes can lead to more readable and maintainable code. It is useful for developing object models in your component.
Can we declare private class in namespace ?There are only two valid declarations for a class at the namespace level, "Internal" and "Public". The only exception to this is nested class, where private visibility means that derived classes will have access to the inner class. More about.... private class in name space
In C# -- all nested classes are implicitly static.
- What is object-oriented programming?
- What is a Class?
- What is an Object?
- Constructors and Destructors
- What Is Inheritance ?
- What are the different types of inheritance ?
- What are Access Modifiers ?
- Why Classes cannot be declared as Protected?
- Can we declare private class in namespace
- Difference between Classes and Structures
- Can we use pointers in C# ?
- Why abstract class can't create instance
- Can you prevent your class from being inherited
- Difference between method Overloading and Overriding
- Difference between Early Binding and Late binding
- What is partial class ?
- What is Virtual Method
- Difference between class and object
- What is Data Encapsulation?
- Object Based Language and OOPs
- SOLID Principles in Object-Oriented Programming
- Solid Principles | Advantages and Disadvantages