473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1770
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
2
by: Josh Mcfarlane | last post by:
I'm doing recomposition of objects from binary streams, and the best way for me to write them out is to write base class data first, forward to inherited classes, pointer class values, etc. Now,...
4
by: C-Sharper or C-Hasher, one of the two | last post by:
Hi, I have a C# class libary (Class1) which is inherited by another class in a Windows Forms app. I want this other class to implement some, but not all of the features of the base class. How...
6
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
8
by: TS | last post by:
I am trying to get set a property of a control on the inherited class from base class. I imagine i have to use reflection, so could someone give me the code to do it? something like this?...
12
by: Ray Cassick \(Home\) | last post by:
Ok, I have finally decided that there is ONE big thing about VB.NET (not sure if this same thing exists in C# yet) that really ticks me off. Either I am missing the point here or I have not found...
3
by: Jeff User | last post by:
Hello I am using C#, .net1.1 Vis Studio 2003 I am using homeBase.aspx.cs page as a base for several other aspx/aspx.cs web pages. The base page handles some operations that are common to all...
8
by: Mike C# | last post by:
Suppose I have a base class "foo". Another class, "bar" derives from it. Base class "foo" has a method called "rob_the_liquor_store()", and the inherited class "bar" overrides this method with one...
19
by: jan.loucka | last post by:
Hi, We're building a mapping application and inside we're using open source dll called MapServer. This dll uses object model that has quite a few classes. In our app we however need to little bit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.