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

In gridview in editmode if we want to display information in one combobox based on

0 Answers   FD, Microsoft,


What is join in c#?

0 Answers  


what are windows services?

0 Answers  


Explain about generics in c#.net?

0 Answers  


What is data adapter in c#?

0 Answers  






What is a .exe extension files? How is it similar to .dll extension files?

0 Answers   Accenture,


What is difference between ienumerable and ienumerator in c#?

0 Answers  


Why do we use delegates in c#?

0 Answers  


What are the properties of a string class?

0 Answers  


How can I make sure my c# classes will interoperate with other .net languages?

0 Answers  


What is a sealed class?

0 Answers  


What type is string in c#?

0 Answers  


Categories