473,320 Members | 1,930 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,320 software developers and data experts.

How do I override a class's properties?

Hi!
I want to make a base class with some base properties and then derive
different other classes from that in which I want to override the base
properties to get specialized behaviour unique for each derived class as
follows:

MyBaseClass {PropertyA…}
MyDerivedClassA: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassB: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassC: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)

Suppose that PropertyA is a form, on which I want to put different kinds or
numbers of controls in each class.

Is this possible to do? Which techniques are to be used?

Regards,
M Shafaat
Nov 17 '05 #1
3 4464

"M Shafaat" <MS******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
Hi!
I want to make a base class with some base properties and then derive
different other classes from that in which I want to override the base
properties to get specialized behaviour unique for each derived class as
follows:

MyBaseClass {PropertyA…}
MyDerivedClassA: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassB: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassC: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)

Suppose that PropertyA is a form, on which I want to put different kinds
or
numbers of controls in each class.

Is this possible to do? Which techniques are to be used?

Regards,
M Shafaat


If you base class is never created and always inherited...and all of it's
property and methods are always overridden, then why not make the base class
an Interface?

Mythran

Nov 17 '05 #2
An interface can not contain any implementation (i.e. code). If the
base class is not (and should not) ever be instantiated, it can be
marked 'abstract' which means it must always be inherited from.
thanks, jabits

Nov 17 '05 #3
What I want to do is to reference and treat my inherited classes as the
BaseClass, like this:

for each MyBaseClass MyClass in MyCollection
{ MyClass.DataForm.show() }
…

MyCollection here above may keep all types of inherited classes from
MyBaseClass.

I want to treat all the inherited classes in one single line of code in
stead of using hard coding like:

case MyClass
MyDerivedClassA:
{…}
MyDerivedClassB:
{…}
…

Regards
M Shafaat
"Mythran" wrote:

"M Shafaat" <MS******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
Hi!
I want to make a base class with some base properties and then derive
different other classes from that in which I want to override the base
properties to get specialized behaviour unique for each derived class as
follows:

MyBaseClass {PropertyA…}
MyDerivedClassA: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassB: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassC: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)

Suppose that PropertyA is a form, on which I want to put different kinds
or
numbers of controls in each class.

Is this possible to do? Which techniques are to be used?

Regards,
M Shafaat


If you base class is never created and always inherited...and all of it's
property and methods are always overridden, then why not make the base class
an Interface?

Mythran

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Robin Becker | last post by:
Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
5
by: Darius | last post by:
I'm writing here in hopes that someone can explain the difference between the new and virtual/override keywords in C#. Specifically, what is the difference between this: public class Window {...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
15
by: John Salerno | last post by:
Hi all. I have a question about virtual and override methods. Please forgive the elementary nature! First off, let me quote Programming in the Key of C#: "Any virtual method overridden with...
4
by: TJS | last post by:
How can I override the default values, of a class constructor , from an ASP.net page ? Public Sub New( ) HeaderStyle.BackColor = ColorTranslator.FromHtml("#5C85AD") HeaderStyle.ForeColor =...
5
by: Marcel Hug | last post by:
Hi NG ! I'm new in C# and I'm reading a book about the fundamentals and concepts. In the chapter Methods it's written to use virtual, if i would like to override the method in a subclass. This...
2
by: slolife | last post by:
See any problem with this code: Here's my Base page class: Public Class BasePage Inherits System.Web.UI.Page Protected m_NeedAlerts As Boolean Private Sub Page_Init(ByVal sender As...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.