*Experts* Bucky Posted February 15, 2003 *Experts* Posted February 15, 2003 How do I hide a base class member (a method in this case) so that only the member of the inherited class can be used, even if the members are of different types and have different parameters? Take the following example: public class BaseClass { public string Moo() { return "Base class moo!"; } } public class InheritedClass : BaseClass { public string Moo(string text) { return "Inherited class moo! - " + text; } } As you can see, the InheritedClass.Moo() method will overload the Moo method for that class. But how can I make it so that the inherited method overrides the base method, even though they have different parameters? This can be accomplished in VB.NET with the Shadows modifier, but what is the C# equivalent? Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Experts* Volte Posted February 15, 2003 *Experts* Posted February 15, 2003 I think new public string Moo is what you're looking for. Quote
*Experts* Bucky Posted February 17, 2003 Author *Experts* Posted February 17, 2003 I looked into the new modifier, but it seems that it can only be used on a method that hides another method with the same parameters. In this case, however, the methods have different parameters, so it won't work. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.