我是一個新手,VB,和我有難以理解以下(遺留代碼)類的聲明實際上意味着:遞歸泛型類型聲明在VB.Net
Public MustInherit Class ModelBase(Of T As {ModelBase(Of T, TIdType), New}, TIdType)
誰能解釋一下上面的?還有一個相關的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)
我很難理解爲ModelBaseCollection
類的需求爲ModelBase
類是一個泛型類型。
嗯......遞歸泛型。如果您瞭解C#,請看看這個:http://fernandof.wordpress.com/2007/09/23/recursive-generics-restrictions/ – 2011-03-23 19:19:21
[Curiously Recurring Template Pattern and generics constraints(C#)]( http://stackoverflow.com/questions/1327568/curiously-recurring-template-pattern-and-generics-constraints-c) – 2011-03-23 19:43:59