|
VB.NET • Search an EmployeeCollection Listing 2. This method searches a given EmployeeCollection for the first CEO found in the collection and returns his or her years of service as an output parameter of the method. <WebMethod(False)> _
Public Function CEOYearsOfService( _
ByVal employees As EmployeeCollection) _
As Short
Debug.Assert(Not employees Is Nothing)
Dim employee As Employee
For Each employee In employees
If TypeOf employee Is CEO Then
Return CType(employee, _
CEO).YearsOfService
End If
Next
Throw New Exception("No CEO found " & _
"in collection.")
End Function
|