Can we declare a class protected
You cannot declare protected classes at the namespace level because the access modifier for outer level classes defines their visibility in relation to other assemblies. The protected visibility is used to indicate 'visible to derived classes'; this makes sense on things inside a class, but normally has no meaning at the class level.
Why Classes cannot be declared as Protected?
There are only two valid declarations for a class at the namespace level, "Internal" and "Public". The only exception to this is an inner class, where protected visibility means that derived classes will have access to the inner class.
The .Net Framework allows you to define a class within another class. Such class is called a nested 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. More about.... What is nested class ?
Are private class variables inherited ?
An inherited class has access to the public, protected, internal, and protected internal members of a parent class. Even though a derived class inherits the private members of a base class, members marked private are not accessible to derived classes for integrity purpose. You can access private variables/methods from a derived class using reflection or mark the members as protected.
- 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 ?
- 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 nested class
- What is partial class ?
- What is Virtual Method
- Difference between class and object
- What is Data Encapsulation?
- Object Based Language and OOPs