c# inheritance probelm anyone?

Get help on programming - C++, Java, Delphi, etc.
Post Reply
FireFlyComputerSystems
Registered User
Posts: 26
Joined: 01 Jun 2008, 02:00

c# inheritance probelm anyone?

Post by FireFlyComputerSystems »

Hi

I'm extending some .NET classes. The classes are ASP controls, textbox, dropdownlist, etc.

The above classes are all extended with exactly the same properties. Therefore it makes sense to abstract those properties to the base class. This will then allow me to conver to to and from that base class with my new properties. There's also the advantage of less source code overhead.

My probelm is then, how do you extend the base class of a set of classes so that those extension are automatically propagated to all the child classes? Can this be done with C# .NET ASP 3.5?
Kronos
Moderator Emeritus
Posts: 4280
Joined: 28 May 2003, 02:00
Location: Azeroth
Contact:

Post by Kronos »

I'm not exactly sure what you want to tell us here. Give an example. Either pictorially, or pseudocode...
Image
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Post by Ron2K »

Basically:

Code: Select all

public class BaseClass
{
   // class implementation goes here
}

public class ChildClass : BaseClass
{
   // class implementation goes here
}
If you do not intend to create instances of your base class and thus will only use it for abstraction purposes, specify the "abstract" keyword in the class definition.
Kia kaha, Kia māia, Kia manawanui.
Post Reply