我有List(of BodyComponent)
中的对象BodyComponent
是基类,添加到列表中的项目beeing是来自派生类的对象。现在投掷对象返回原始类型
Public Class Body_Cylinder
' Get the base properties
Inherits BodyComponent
' Set new properties that are only required for cylinders
Public Property Segments() As Integer
Public Property LW_Orientation() As Double End Class
我想将对象转换回它的原始类Body_Cylinder
因此,用户可以输入对象类的一些特定的值。
但是我不知道该怎么做这个操作,我找了一些相关的帖子,但是这些全都写在c#
里面我没有任何的知识。
我想答案可能是在这里,但..不能读取Link
如果你知道类型,你可以使用[ CTYPE](https://msdn.microsoft.com/en-us/library/4x2877xb.aspx)。 CType(theList(0),Body_Cylinder).Segments = 0 –
链接是指拳击,这是比你想要的略有不同。由于该基地有一个itemtype属性使用它来知道它是哪个,然后'CType'进行转换。 – Plutonix