473,320 Members | 1,987 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.

Defining constructors in an interface

SA
Hi all,

How could I go about defining ctors in an interface. (not to instantiate the
interface, of course, but to force the implementing class to provide a
specific ctor).

Sub New(ByVal x as MyType) doesn't work.

May be it's not possible, in which case it should be on the to-do list for
future versions...

--

Sven

Nov 20 '05 #1
2 988
Bob
It's not possible and by some people's thinking (sorry, the thread is not on
the news server any more) it's "the exception that proves the rule" because
you can't instantiate an interface.

I think that's crap, because the compiler already throws an exception when
you try to instantiate a bare interface; allowing constructors in interface
definitions would cause no harm, and fill a gaping hole in the few (i.e.
serialization) that actually require certain constructor signatures to work.

Unfortunately I don't think it's on the list of 2005 enhancements.

Bob

"SA" <in*********@freemail.nl> wrote in message
news:ec**************@tk2msftngp13.phx.gbl...
Hi all,

How could I go about defining ctors in an interface. (not to instantiate the interface, of course, but to force the implementing class to provide a
specific ctor).

Sub New(ByVal x as MyType) doesn't work.

May be it's not possible, in which case it should be on the to-do list for
future versions...

--

Sven


Nov 20 '05 #2
SA
Bob:

Thanks for the answer, even though it isn't what I expected... :o)

--

Sven
"Bob" <no****@nowhere.com> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
It's not possible and by some people's thinking (sorry, the thread is not on the news server any more) it's "the exception that proves the rule" because you can't instantiate an interface.

I think that's crap, because the compiler already throws an exception when
you try to instantiate a bare interface; allowing constructors in interface definitions would cause no harm, and fill a gaping hole in the few (i.e.
serialization) that actually require certain constructor signatures to work.
Unfortunately I don't think it's on the list of 2005 enhancements.

Bob

"SA" <in*********@freemail.nl> wrote in message
news:ec**************@tk2msftngp13.phx.gbl...
Hi all,

How could I go about defining ctors in an interface. (not to instantiate

the
interface, of course, but to force the implementing class to provide a
specific ctor).

Sub New(ByVal x as MyType) doesn't work.

May be it's not possible, in which case it should be on the to-do list for future versions...

--

Sven

Nov 20 '05 #3

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

Similar topics

42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
7
by: Jay Douglas | last post by:
Greetings, I have a Windows form application that (naturally) instantiates all sorts of objects. I have a base object that contains an event. Lots of other objects inherit from this event. ...
4
by: Adam | last post by:
Okay, so I know this will come off as a stupid question...but I am going to ask it anyways... I know you are not allowed to have constructors defined in an interface, but why not? I really...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.