Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

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?

"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*
Posted

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.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...