I wonder what the rationale for this restriction is
Geoff Appleby discovers that a common C++ template idiom doesn't work with .Net generics. The code that doesn't work is this:
Public Class Class1(Of V As System.Web.Services.Protocols.SoapHttpClientProtocol)
Inherits V
End Class
which is the .Net generics equivalent of this common C++ idiom:
template <class base>
class TDerived : public base
{
};
This is useful in all kinds of situations, as
Christopher Diggins explains and, as Geoff says:
"You don't know if V is NotIneritable, MustInherit, or whatever. It would surely fail at compile time if that happened" which is fine. Failing at compile time is great and means that this idiom is safe to use as you can't generate code that isn't legal; so what's the rationale behind the restriction?
Share this entry: Email it! | bookmark it! | digg it! | reddit!
Posted by Len at August 17, 2005 07:09 PM
| Comments (0)
| Categories : .Net
, Geek Speak
Copyright © 1990-2010 Len Holgate. All Rights Reserved.