C# won't allow this either (for the same reasons: you can't have multiple definitions of GenericClass<t>, and types used for constraints can't be sealed). However, it looks to me like perhaps what you really want is for the inheritance to go the other direction:

1
2
3
4
5
6
7
type GenericClass<'a> = ...
type FastGenericClassImpl_Int16 =
  inherit GenericClass<int16>
  ...
type FastGenericClassImpl_Int32 =
  inherit GenericClass<int32>
  ...
By on 7/31/2010 6:06 AM ()

You're right. I dug out some of my old C# code and that's what I did. The way I hid it from the users was to hide the constructor and make them use a static Create() method on the generic class that returned the appropriate concrete implementation for the type they wanted.

By on 7/31/2010 11:26 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper