我有以下的說法,我希望把它變成一個公共共享功能:申報返回類型時,有兩種可能的返回類型
If isEmployee Then
Dim employeeInstance As New Employee
employeeInstance = GetEmployeeInstanceByUserId(userId)
Return employeeInstance
Else
Dim studentInstance As New Student
studentInstance = GetStudentInstanceByUserId(userId)
Return studentInstance
End If
公共共享功能GetWorkerInstance(BYVAL isEmployee布爾)作爲...(不知道這裏寫什麼)...
有兩種可能的返回類型。我不知道我應該爲函數返回類型聲明什麼。
有什麼建議嗎?謝謝。
你能不能創建一個Person類,使他們既繼承? – Geo 2010-01-25 07:59:57
我正在使用LINQ to SQL,這些是由LINQ自動生成的類。 – 2010-01-25 08:17:06