new constraint in generics

  • Thread starter Thread starter Alex Shirshov
  • Start date Start date
A

Alex Shirshov

Hi all!

How can i specify, that the generic class have the constructor?
With c# it's a new constraint.

For instance, i write
Code:
Class cls1(Of T)
Public Sub some()
Dim tt As New T() ' here is an error: 'New' cannot be used on a
type parameter not declared 'As New()'.
End Sub
End Class

Ok. Next try
Code:
Class cls1(Of T as New()) ' another error: Keyword does not name a type.
Public Sub some()
Dim tt As New T() 'previos error still here
End Sub
End Class
Now i have two error message!

Can anyone help?

P.S. My versions is VS.NET Whidbey 8.0.30703.4. and the .NET Framework
1.2.30703
 
Alex,
How can i specify, that the generic class have the constructor?

This didn't work in the PDC alpha release, but I believe it will in a
future beta release.



Mattias
 
Back
Top