When would you use the protected internal and internal access modifier?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaish MathewsRank #225 · 11K reputationPosted May 6, 2010, 12:35 AM EDT
eg:-
// Assembly1.cs // compile with: /target:library internal class BaseClass { public static int intM = 0; }// Assembly1_a.cs // compile with: /reference:Assembly1.dll class TestAccess { static void Main() { BaseClass myBase = new BaseClass(); // Compile erro will get. } }Access is limited to the current assembly or types derived from the containing class. Eg:- Assembly1 class- public class Class1 { protected internal void Class1Test() { } } Assembly2 class class Class3 : Class1 { private void Test() { Class3 clss = new Class3(); clss.Class1Test(); } } As you can see, if yu want to ensure a class member accebility through it's inherit class only, use this pattern