Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
plz anybody reply me...........
Posted

If you mean a method in a class that can't be accessed by derived classes, then just declare it private

C#
public class myBase
   {
   ...
   private void methodA() {}
   protected void methodB() {}
   }
public class myDerived : myBase
   {
   ...
   private void methodC()
      {
      methodA();   //Illegal - compiler will complain.
      methodB();   //Legal
      }
   }
 
Share this answer
 
Comments
Reiss 1-Aug-11 11:07am    
I think this is what the OP is after, if so then this is correct
C#
public class IAmYourDad
{
    public void Test()
    {
    }
}
public class IAmTheChild : IAmYourDad
{
    //this is not visible to Parent
    private string DoNotTellThisToMyDad()
    {
        return "Secret";
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900