inheriting constructors in vb.net

  • Thread starter Thread starter Brad Langhorst
  • Start date Start date
B

Brad Langhorst

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
 
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
 
Andrea Saltarello said:
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
 
Back
Top