I’m a newbie to VB, and I am having difficulty understanding what the following (legacy code) class declaration actually means:
Public MustInherit Class ModelBase(Of T As {ModelBase(Of T, TIdType), New}, TIdType)
Can anyone explain the above? There is also a related ModelBaseCollection:
Public MustInherit Class ModelBaseCollection(Of TCollection As {ModelBaseCollection(Of TCollection, TModel, TIdType), New}, TModel As {ModelBase(Of TModel, TIdType), New}, TIdType)
Inherits Collection(Of TModel)
I have difficulty understanding the need for the ModelBaseCollection class as the ModelBase class is a generic type.
Given the lack of an answer for over 8 months, the comments referring to the Curiously Recurring Template Pattern have been seen (correctly) as solutions.
Nevertheless, this can be explicitly described:
It is publicly accessible and cannot be created directly, but must be inherited to use;
It is a generic class where the specified classes are:
a creatable class inheriting from this class, and
another type.
Without seeing the rest of the code, the
ModelBaseCollectionis just the same sort of construct, being able to refer to creatable versions of (an inherited class of) itself and the correspondingModelBase.