difference between keyword internal and protected?

Answers were Sorted based on User's Feedback



difference between keyword internal and protected?..

Answer / jebasingh luccas

Major different between these internal and protected
keyword reside on scope in which it can be accessible.
internal defines the scope with in the assembly and
protected defines the scope to the derived
(sub) class.

Is This Answer Correct ?    39 Yes 6 No

difference between keyword internal and protected?..

Answer / dotnetasit

The keywords 'internal' and 'protected' are access modifiers.
If any member in a class is qualified with access
modifier 'internal', then it is friend to the current assembly
but not outside of it. This means any member or class(but not
the dervied classes) within the current assembly can access it.

On the other hand, any member qualified with access
modifier 'protected' can be accessed by derived classes only.

I also want to tell about the combined access
modifier 'protected internal'. Any member qualified with
access modifier 'protected internal' is accessible to the
derived classes as well as to any member or class within the
same assembly. So in a way, this combined modifier extends the
scope of 'internal'.

Is This Answer Correct ?    25 Yes 2 No

difference between keyword internal and protected?..

Answer / 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

difference between keyword internal and protected?..

Answer / pawan

protected and internal can be accessed in the derived class
which can be in different namspaces.

Protected can not be accessed using object, it dosen't
matter whether it is in same or different namespace.

Only internal method will be accible using object

Is This Answer Correct ?    1 Yes 5 No

difference between keyword internal and protected?..

Answer / ghouse basha s

These are access specifiers,
Internal means methods and properties will be accessible to
Classes in the Assembly
Protected means methods and properties will be accessible to
classes and in the derived assembly

Is This Answer Correct ?    7 Yes 21 No

Post New Answer

More C Sharp Interview Questions

What is a method signature?

0 Answers  


What is a delegate how is it type safe?

0 Answers  


What is a template class?

0 Answers  


What is asp net c# corner?

0 Answers  


What is Dispose method in .NET ?

9 Answers   247Customer, KAP, TCS,






Can we store different data types in arraylist in c#?

0 Answers  


Define a strong name in .net?

0 Answers  


What is interface inheritance?

0 Answers  


Can we have multiple threads in one app domain?

0 Answers  


what is difference between destruct or and garbage collection ?

0 Answers   Wipro,


what is the difference between a struct and a class in c#?

0 Answers   4Cplus,


Describe a Struct ?

0 Answers   Siebel,


Categories