【发布时间】:2014-11-04 04:19:06
【问题描述】:
我可以从一个类继承,并为我的新类添加属性...这一切都很好。
Class class1
Property a as string
End Class
Class class2
inherits class1
property b as string
End Class
Dim mytest as new class2
mytest.a = "bleh"
mytest.b = "bah"
如何将属性添加到我正在继承的类中的子类?
Class class3
Property a as string
Class class3_1
Property c as string
End Class
End Class
如何创建一个继承 class3 的新类,但在我的新继承类中向 class3_1 添加一个属性?
带有实际非工作代码的新编辑
Public Class testclass
Public Class class1
Property x As String
Property firstChildClass As New class1_1
Public Class class1_1
Property a As String
End Class
End Class
Public Class inherited_class1
Inherits class1
Public Class class1_1 '///// Warning here to use "Shadows" keyword.. but that also does not work... takes away the warning, but still cant access property b when using a new instance of class
Property b As String
End Class
End Class
Sub test()
Dim myTestClass As New inherited_class1
myTestClass.firstChildClass.b = "blah" '///// This does not work...
End Sub
End Class
【问题讨论】:
标签: .net vb.net class oop inheritance