我們有兩個類BasicRace & AdvancedRace。 AdvancedRace繼承BasicRace將基類擴展爲派生類
我有一個BasicRace,但我想'轉換'爲高級類。下面
見代碼作爲例子:
Module Module1
Sub Main()
Dim bRace As New BasicRace With {.CourseID = 1, .MeetingDate = "2013-05-01", .RaceNumber = 1}
Dim aRace As New AdvancedRace
' Upgrade bRace to AdvancedRace???????
End Sub
End Module
Public Class BasicRace
Public Property MeetingDate As Date
Public Property CourseID As Integer
Public Property RaceNumber As Integer
End Class
Public Class AdvancedRace
Inherits BasicRace
Public Property RaceTitle As String
End Class
任何幫助將是巨大的 - 我開始覺得不能這樣做,除非我寫一個函數來轉換basicRace到AdvancedRace通過每個屬性去逐個?
你可以寫一個高級種族的構造函數,它接受了基本種族的參數,並且這樣做。 – Nomad101 2013-05-03 08:18:20
我如何將basicRace傳遞給AdvancedClass的基礎? – user2346043 2013-05-03 08:27:23