472,098 Members | 2,545 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,098 software developers and data experts.

Hide base mambers in an inherited class

Hi all,

I'm trying to hide a member from a base class, like so :
public class class1
{
public class1()
{
}
public int i;
}

public class class2 : class1
{
public class2()
{
}
private new int i;
}

This article :
http://msdn.microsoft.com/library/de...ec_3_7_1_2.asp
, like others, states that now, class2 shouldn't have a property i.

Unfortunatelly, it still does.

My goal eventually is to create a custom user control inherited from
CustomValidator that doen not has a ServerValidate event.

Any ideas on how you cab hide properties and events?,
Greetz,
Owin
Amsterdam

Nov 16 '05 #1
2 1704
owingruters <ow*********@hotmail-dot-com.no-spam.invalid> wrote:
I'm trying to hide a member from a base class
Bad idea.
, like so :
public class class1
{
public class1()
{
}
public int i;
}

public class class2 : class1
{
public class2()
{
}
private new int i;
}

This article :
http://msdn.microsoft.com/library/default.asp?url=
/library/en-us/csspec/html/vclrfcsharpspec_3_7_1_2.asp
, like others, states that now, class2 shouldn't have a property i.

Unfortunatelly, it still does.
Actually, it doesn't - it doesn't have any properties. It still has a
publically available i variable, however.

Name hiding doesn't actually make anything unavailable, it just changes
how you have to access the member in question.
My goal eventually is to create a custom user control inherited from
CustomValidator that doen not has a ServerValidate event.


You won't be able to do that, and a good job too - it would break the
Liskov Substitutability Rule. It sounds like you might want to
encapsulate CustomValidator instead of inheriting from it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi Jon,

Thanx for answering!
I understand what u mean, so I'll just leave the ServerValidate event
available for my users!

Owin

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Josh Mcfarlane | last post: by
4 posts views Thread by C-Sharper or C-Hasher, one of the two | last post: by
12 posts views Thread by Ray Cassick \(Home\) | last post: by
3 posts views Thread by Jeff User | last post: by
8 posts views Thread by Mike C# | last post: by
19 posts views Thread by jan.loucka | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.