我想声明一个属性作为一个接口的接口集合,我想稍后在构造函数中实例化显式类型。像这样的东西。属性和接口
Public Class LicenseFile
Implements ILicenseFile
Public Property Collection As IList(Of ILicenseFileDataNode)
Public Sub New()
Collection = New List(Of LicenseFileDataNode) 'here throws an exception.
End Sub
End Class
当然,LicenseFileDataNode器具ILicenseFileDataNode
构造独特的线发动例外又说什么:
“类型 “System.Collections.Generic的目的。列表
1[NtnAgent.LicenseFileDataNode]' can't be converted to an object of the type 'System.Collections.Generic.IList
1 [NtnAgent.IRCANFileDataNode]'。
总之,t他的问题是“为什么它不工作”?这是一个简化的方案,但很容易采取一个工作周期,但我需要了解原因,因为它失败了。
谢谢!
+1。为了进一步研究,Google协方差和逆变。 – StriplingWarrior 2011-02-07 16:46:00