469,273 Members | 1,658 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,273 developers. It's quick & easy.

To Hide inherited members

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
5 8468
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
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
"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
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
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.

Similar topics

4 posts views Thread by C-Sharper or C-Hasher, one of the two | last post: by
2 posts views Thread by Giojo | last post: by
14 posts views Thread by lovecreatesbea... | last post: by
19 posts views Thread by jan.loucka | last post: by
2 posts views Thread by eggie5 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.