use of internal protected ?
Please explain me the use of keyword internal protected with an example ??
what is the difference between inetrnal protected and protected ??
Can construstor be declared protected ?? why or why not?
Leave a comment...
- 4 Comments
If we use "protected" before a method/variable, it can be accessed only to derived class.
If we use "internal" before a method/variable, it can be access only within the same assembly.
So, internal protected can be accessed within the same assembly as well as in derived class.
protected constructors - Yes, you can use I think. Below is some Info.#1; Sun, 06 Jan 2008 06:51:00 GMT
As to internal protected I thinkVIDAS completelly answered your question. My two cents for the protected constructor:
In most cases we do use protected constructor to make sure that only derived classes able to call it. This is similar to abstract class - we can't create instance of abstract class and we can't create instance of class with only protected constructor available.#2; Sun, 06 Jan 2008 06:52:00 GMT
Agreed...i made the constructor protected in a class say i got the error " inaccessible due to its protection level "......but i created another class inherting from class1 and creating object
it works absolutely fine ....................
Please explain with a example about internal and internal protected or give me some god links ...
suppose my assembly is AS1 and the class having inetrnal protected variable is C1->AS1
Now variables is accesseible to all classes in AS1(assembly) . Now if i have a class in assembly AS2 i.e class C2->AS2 and i inherit the C2 from C1 (in assembly AS1) will it be accessible to C2??
Does this is the significance of internal protected?
Thanks in advance...
Please explain if i m rong anywhere?#3; Sun, 06 Jan 2008 06:53:00 GMT
- Now if i have a class in assembly AS2 i.e class C2->AS2 and iinherit the C2 from C1 (in assembly AS1) will it be accessible to C2??
Yes, and only for all derived classes in AS2. None of the other code in AS2 able to access it.#4; Sun, 06 Jan 2008 06:54:00 GMT