我有以下的说法,我希望把它变成一个公共共享功能:申报返回类型时,有两种可能的返回类型
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