473,554 Members | 2,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1782
owingruters <ow*********@ho tmail-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 Substitutabilit y Rule. It sounds like you might want to
encapsulate CustomValidator instead of inheriting from it.

--
Jon Skeet - <sk***@pobox.co m>
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
4326
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 inherited base member's access level in the derived class: its access level in the base class and the type of inheritance (public, protected, or...
2
2147
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, when recomposing these objects, I first read the base class data, and can create a base object. When I find the inherited class marker, can I...
4
6739
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 can I completely hide (within the IDE) the members of the base class library i.e. only expose those members that I want exposed? I've tried some...
6
3008
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
8
3059
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? this.GetType().GetMember("panel1").SetValue(xx).Left = 44;
12
13352
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 what I need to accomplish my need. I am creating a Windows forms user control and am inheriting from System.Windows.Forms.UserControl. There are...
3
1777
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 pages. like this: somepage... public class homeBase : System.Web.UI.Page .... then other pages.....
8
2005
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 of its own, maybe specifying the liquor store over on 44th Street and 5th Avenue or something. Anyway this is what we have so far: base class:...
19
2213
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 modify come of the classes so they match our purpose better - mostly add a few methods etc. Example: Open source lib has classes Map and Layer...
0
7496
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7527
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3538
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1992
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1109
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.