Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

How to hide a method?

Is there no other way, maybe with an attribute, to hide a method? Now I need to call Shell.List to access methods, otherwise I need to specify all methods in Shell class if I what them to bee accessed directly.
public class Shell{
   private class MyList : List<object>, IAllowableFunctions{
      //define functions here
   }
   
   public interface IAllowableFunctions{
      //define functions u want to be declared public here
      void Add();
 
      void Remove();
   }
 
   private MyList list;
 
   public Shell(){
      list = new MyList();
   }
 
   //returns back a IAllowableFunctions interface that only
   //has access to the listed functions
   public IAllowableFunctions List{
      get{ return list; }
   }
}

Open in new window

0
HOVE
Asked:
HOVE
  • 6
  • 4
1 Solution
 
silemoneCommented:
change them to private...use reflection and you can change the public, private, etc...of a method...
0
 
silemoneCommented:
hmm...pls explain more...
0
 
HOVEAuthor Commented:
That is it you are talking about, just be more specific. What to use from System.Reflection and how?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
silemoneCommented:
I'm leaving right now, but I will let you know later tonight...
0
 
HOVEAuthor Commented:
To clarify, I need to hide some system base class public methods.
0
 
HOVEAuthor Commented:
Pardon me, not system base class, but system class public methods in derived class.
0
 
silemoneCommented:
I spoke too soon...from my java background you can do this with reflection...at least back in 1.5.1...looking at this:

http://stackoverflow.com/questions/106383/c-can-publicly-inherited-methods-be-hidden-eg-made-private-to-derived-class 

it appears you can't in java...

however, look at the last response (read all of them...they are interesting) for Method hiding...
0
 
silemoneCommented:
I spoke too soon...from my java background you can do this with reflection...at least back in 1.5.1...looking at this:

http://stackoverflow.com/questions/106383/c-can-publicly-inherited-methods-be-hidden-eg-made-private-to-derived-class

it appears you can't do in C# what you can in java...

however, look at the last response (read all of them...they are interesting) for Method hiding...
0
 
silemoneCommented:
did that work out for you?  did you use 'new' keyword to hide method?
0
 
HOVEAuthor Commented:
If you change methods access modifier and add a new keyword, you could still access base public method. That didn't help me, I gave up on method hiding.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now