(c) 2003 Visual Studio Magazine 
Fawcette Technical Publications

VB.NET	Listing 1
Build the Employee Base Class. The Employee class forms the basis for both the EmployeeCollection class and the derived Employee classes-CEO, Secretary, and Programmer.

Public MustInherit Class Employee
	Public Property Name() As String
		Get
			Return _name
		End Get
		Set(ByVal Value As String)
			_name = Value
		End Set
	End Property
	Public Property Salary() As Double
		Get
			Return _salary
		End Get
		Set(ByVal Value As Double)
			_salary = Value
		End Set
	End Property
	Private _name As String
	Private _salary As Double
End Class


VB.NET 	Listing 2
Search an EmployeeCollection. This method searches a given EmployeeCollection for the first CEO found in the collection and returns his or her years of service for their company 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 years As Short
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


