Shadowing

Bucky

Well-known member
Joined
Dec 23, 2001
Messages
791
Location
East Coast
User Rank
*Expert*
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:

C#:
		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?
 
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 wont work.
 
Back
Top