Public Class MyOwnClassCollection Inherits System.Collections.CollectionBase Public Sub Add(ByVal aMyClass As MyOwnClass) List.Add(aMyClass) End Sub Public Sub Remove(ByVal index As Integer) If index > Count - 1 Or index < 0 Then ' تعريف استثناء Dim Exc As New Exception("لا يوجد عنصر بهذا الرقم.") ' إطلاق الاستثناء Throw Exc Else ' إضافة العنصر List.RemoveAt(index) End If End Sub Public Property Item(ByVal index As Integer) As MyOwnClass Get If index > Count - 1 Or index < 0 Then Dim Exc As New Exception("لا يوجد عنصر بهذا الرقم.") Throw Exc Else Return CType(List.Item(index), MyOwnClass) End If End Get Set(ByVal Value As MyOwnClass) If index > Count - 1 Or index < 0 Then Dim Exc As New Exception("لا يوجد عنصر بهذا الرقم.") Throw Exc Else List.Item(index) = Value End If End Set End Property End Class