Connecting Tech Pros Worldwide Forums | Help | Site Map

Declaring constructor interfaces [in interfaces]

Ruffin Bailey
Guest
 
Posts: n/a
#1: Nov 20 '05
I want to declare an interface that forces the presence of a certain
constructor (in this case, "Sub New(ByVal ds As DataSet)"). When I
try, I get a

'Sub New' cannot be declared in an interface.

.... error.

Now I could create an object that implements the interface that
includes the contructor and extend it, sure, but as I understand it,
VB.NET isn't going to let me use multiple inheritence, and I need the
interfaces to be implemented by Controls (Panels and UserControls,
mostly). So creating an object with the constructor really isn't an
option.

Is there a way I can declare/require the existence of a certain
constructor in an "interface-like fashion"?

Thanks,

Ruffin Bailey

--
Wasted bandwidth from a "professional" programmer
http://myfreakinname.blogspot.com

CJ Taylor
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Declaring constructor interfaces [in interfaces]


You might want to look into a Factor design pattern...

http://www.dofactory.com/Patterns/Patterns.aspx#list


"Ruffin Bailey" <kaboom@atari.net> wrote in message
news:172e9d35.0402201004.588b7760@posting.google.c om...[color=blue]
> I want to declare an interface that forces the presence of a certain
> constructor (in this case, "Sub New(ByVal ds As DataSet)"). When I
> try, I get a
>
> 'Sub New' cannot be declared in an interface.
>
> ... error.
>
> Now I could create an object that implements the interface that
> includes the contructor and extend it, sure, but as I understand it,
> VB.NET isn't going to let me use multiple inheritence, and I need the
> interfaces to be implemented by Controls (Panels and UserControls,
> mostly). So creating an object with the constructor really isn't an
> option.
>
> Is there a way I can declare/require the existence of a certain
> constructor in an "interface-like fashion"?
>
> Thanks,
>
> Ruffin Bailey
>
> --
> Wasted bandwidth from a "professional" programmer
> http://myfreakinname.blogspot.com[/color]


Closed Thread