424,054 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,054 IT Pros & Developers. It's quick & easy.

To Hide inherited members

P: n/a
public abstract class A
{
public virtual MethodOne()
{
}

public void AbstractMethod();

}

public abstract class B : A
{
// How to hide MethodOne and AbstractMethod?
}
Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
Apr 19 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Tommaso Caldarola wrote:
public abstract class A
{
public virtual MethodOne()
{
}

public void AbstractMethod();

}

public abstract class B : A
{
// How to hide MethodOne and AbstractMethod?
}


You can hide them in terms of creating a new method which will be
called if the type is known to be B at compile time, but where A's
version will be called if the type is only known to be A at
compile-time. However, you can't hide them in terms of preventing
people from calling them. Doing so would violate Liskov's Substitution
Principle - you should always be able to treat a derived type as the
base type.

Jon

Apr 19 '06 #2

P: n/a
On Wed, 19 Apr 2006 12:00:40 +0200, Tommaso Caldarola wrote:
public abstract class A
{
public virtual MethodOne()
{
}

public void AbstractMethod();

}

public abstract class B : A
{
// How to hide MethodOne and AbstractMethod?
}


public abstract class B //: A
{
// How to hide MethodOne and AbstractMethod?
}
--
Tom Porterfield
Apr 19 '06 #3

P: n/a
"Tom Porterfield" <tp******@mvps.org> a écrit dans le message de news:
1p***************@tpportermvps.org...

| public abstract class B //: A
| {
| // How to hide MethodOne and AbstractMethod?
| }

Heheh !! Short, sweet and to the point :-)

To explain to the OP, if you need to hide anything from a superclass, you've
got the design wrong.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Apr 19 '06 #4

P: n/a
Hi,

"Tom Porterfield" <tp******@mvps.org> wrote in message
news:1p***************@tpportermvps.org...

public abstract class B //: A
{
// How to hide MethodOne and AbstractMethod?
}


Subtle :)

R u english by any chance?
Apr 19 '06 #5

P: n/a
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

"Tom Porterfield" <tp******@mvps.org> wrote in message
news:1p***************@tpportermvps.org...

public abstract class B //: A
{
// How to hide MethodOne and AbstractMethod?
}


Subtle :)

R u english by any chance?


Nope, American, but I studied English in college.
--
Tom Porterfield
Apr 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.