Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Class design in OOPS protected Internal c#

$
0
0

when we use protected internal any data member of any class then we know that data member can use in same assembly but i did not know that protected internal can be used from other assembly.

code in assembly1

publicclass A{internalprotectedvirtualvoidYoBusiness(){//do something}publicvoid test(){}}class B{// not a derived class - just composites an instance of Apublic B(){
            A a =new A();
            a.YoBusiness();// Thanks friend for the access! }}class D : A{// derived across assembliesinternalprotectedoverridevoidYoBusiness(){// Hey thanks other guy, I can provide a new implementation. }}

code in assembly2

class C : A{// derived across assembliespublic C(){YoBusiness();}protectedoverridevoidYoBusiness(){// Hey thanks other guy, I can provide a new implementation. }}

i knew always that protected internal can be used in same assembly but today know and surprise that any class from other assembly also could override the method......how it is getting possible?

if i want that only the data member can be override or call from same assembly then what i need to do......please discuss. thanks


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>