473,465 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inheriting constructors in vb.net

Books online says that constructors are not inherited in vb.net (grrr - why
not?)

I have a series of classes that share the same constructors and find myself
cutting and pasting when i make changes to them ... a sure sign of something
badly wrong.

How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?

thanks!

brad
Nov 20 '05 #1
4 1938
> I have a series of classes that share the same constructors and find
myself
cutting and pasting when i make changes to them ... a sure sign of something badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?
you can call the base class constructor by means of the MyBase class. Here'
an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class
thanks!
HTH
brad


--
..A [Microsoft MVP .NET]
UGIdotNET - User Group Italiano .NET
http://www.ugidotnet.org
Read my blog at: http://www.ugidotnet.org/4.blog
Nov 20 '05 #2
> I have a series of classes that share the same constructors and find
myself
cutting and pasting when i make changes to them ... a sure sign of something badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?
you can call the base class constructor by means of the MyBase class. Here'
an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class
thanks!
HTH
brad


--
..A [Microsoft MVP .NET]
UGIdotNET - User Group Italiano .NET
http://www.ugidotnet.org
Read my blog at: http://www.ugidotnet.org/4.blog
Nov 20 '05 #3

"Andrea Saltarello [MVP][UGIdotNET]" <pa*********************@phaseit.com>
wrote in message news:OM**************@TK2MSFTNGP11.phx.gbl...
I have a series of classes that share the same constructors and find myself
cutting and pasting when i make changes to them ... a sure sign of

something
badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?

you can call the base class constructor by means of the MyBase class.

Here' an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class


that's what i'm doing now - but I have 10 subclasses and ~8 different
constructors
so i'm cutting and pasting the mybase stuff 10 times...
ugly
Nov 20 '05 #4

"Andrea Saltarello [MVP][UGIdotNET]" <pa*********************@phaseit.com>
wrote in message news:OM**************@TK2MSFTNGP11.phx.gbl...
I have a series of classes that share the same constructors and find myself
cutting and pasting when i make changes to them ... a sure sign of

something
badly wrong.
How do you all deal with sharing this code?
I can't seem to find any sort of #include feature
Is there some option?

you can call the base class constructor by means of the MyBase class.

Here' an example:
public class TheBase
public sub New()

end sub
end class

public class TheDerived : Inherits TheBase
public sub New()
MyBase.New()
end sub
end class


that's what i'm doing now - but I have 10 subclasses and ~8 different
constructors
so i'm cutting and pasting the mybase stuff 10 times...
ugly
Nov 20 '05 #5

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

Similar topics

3
by: sureshsundar007 | last post by:
Hi all, I'm trying to inherit the SimpleWorkerRequest class but cant able to do so. I'm getting an error called "System.Web.Hosting.SimpleWorkerRequest.SimpleWorkerRequest()' is inaccessible...
2
by: SpotNet | last post by:
Hi Newsgroup, Reconstructing my common dialog assembly using C# 2.0 .NET Framework 2.0. I have the following; public class FileDialogBase: System.Windows.Forms.FileDialog { //No constructor...
2
by: Jim Heavey | last post by:
I amd playing around with inheritance a little in VB.Net If I create a new class which inherits from ListViewItem and I am only wanting to override the ToString Method. In this situation, If I...
0
by: Brad Langhorst | last post by:
Books online says that constructors are not inherited in vb.net (grrr - why not?) I have a series of classes that share the same constructors and find myself cutting and pasting when i make...
4
by: elziko | last post by:
I would like to do the following: Create a class that inherits from a usercontrol. Then add a control to the designer Call this new class ClassA. Many controls I need will start off like this...
2
by: TCook | last post by:
Hello All, First I tried to inherit from the TabPageCollection class but received the following error message: No overload for method 'TabPageCollection' takes '0' arguments I also tried...
2
by: Christof Warlich | last post by:
Hi, I'd like to define a class that should behave as much as posible like std::string, but that has some small additional property: class ExtendedString: public std::string { public: void...
0
by: Jack Jackson | last post by:
There is a class (over which I have no control) that has no public constructors - new instances are created via a Static function. I would like to modify the behavior of one of the methods of...
4
by: Thomas Wittek | last post by:
Hi! I'm relatively new to Python, so maybe there is an obvious answer to my question, that I just didn't find, yet. I've got quite some classes (from a data model mapped with SQL-Alchemy)...
4
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 :...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.