difference between keyword internal and protected?
Answer Posted / g2
protected :
This tells that the member is accessible to the derived
class and, in case, the class is a partial class then the
member is accessible to all the other partial classes to
this class. As you can access a protected member declared
in a code behind, you can access it in its respective .aspx
page also. If the member is in a class which is further
derived, it (the member) is available to the derived class
also.
internal :
This tells that the member is accessible any where in the
current assembly or the namespace. It never means that it
has larger scope than the protected. There can be derived
class of a class in other namespaces also. Then the member
with 'protected' will be accessible there but not a member
with 'internal' identifier.
'protected internal' or 'internal protected' :
This combination of identifier is a hybrid of both
protected and internal. But it does not enlarge the
accessibility but shrinks the accessibility instead. It
makes the member accessible to the "DERIVED CLASSES WITHIN
THE CURRENT ASSEMBLY OR NAMESPACE".
| Is This Answer Correct ? | 9 Yes | 13 No |
Post New Answer View All Answers
What is the difference between continue and break statement?
What is dll hell, and how does .net solve it?
How to achieve polymorphism in c#?
Why it's said that writing into .NET Application Configuration Files is a Bad Idea?
What are circular references?
What is predicate builder?
Is class reference type c#?
In which situation(s), the use of "Delegate" is a good idea?
What's new in c#?
What is the use of console application in c#?
What is the main method?
Why is xml called extensible?
if we are updating a database using thread, and mean while application crashes or thread being aborted then what will happen in Database? Rollback or Database will be updated? Please explain with different scenario.
Can you have parameters for static constructors?
When is a class declared as a class abstract?