Re: Generics Question



But that's what I don 't understand. Why can't I create a parameterized
constructor for a class and have its parameter be of an interface type?

Sub New(x As IEmployee)

Then this type would be essentially parameterized, would it not?



"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.21b141f476c8953a644@xxxxxxxxxxxxxxxxxxxxxxx
Scott M. <smar@xxxxxxxxxxxxx> wrote:
I don't know Jon, that's why I asked the question.

Well, you asked it in a way that sounded like you were proposing a
solution. What would your parameterized constructor look like?

In short, to answer your original question: no, you couldn't do
everything that generics offers with interfaces, because interfaces
don't allow you to parameterize types or methods *by types*.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk


.



Relevant Pages


Loading