I have found a few examples of creating your own collection classes (although they all appear to be ripped off from the original MS one on msdn)

but non of them specify information regarding keys. Does any have an example of a custom collection class in .net using keys instead of indexes? or alongside indexes?

VB Code:
  1. 'Copyright (C) 2002 Microsoft Corporation
  2. 'All rights reserved.
  3. 'THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
  4. 'EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  5. 'MERCHANTIBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  6.  
  7. 'Requires the Trial or Release version of Visual Studio .NET Professional (or greater).
  8.  
  9. Option Strict On
  10.  
  11. Public Class Customers
  12.  
  13.     ' The first thing to do when building a CollectionBase class is
  14.     ' to inherit from System.Collections.CollectionBase
  15.     Inherits System.Collections.CollectionBase
  16.  
  17.     Public Overloads Function Add(ByVal Value As Customer) As Customer
  18.  
  19.         ' After you inherit the CollectionBase class,
  20.         ' you can access an intrinsic object
  21.         ' called InnerList that represents your
  22.         ' collection. InnerList is of type ArrayList.
  23.         Me.InnerList.Add(Value)
  24.         Return Value
  25.  
  26.     End Function
  27.  
  28.     Public Overloads Function Add(ByVal FirstName As String, ByVal LastName As String, ByVal AccountNum As String) As Customer
  29.         Dim cust As New Customer()
  30.  
  31.         cust.FirstName = FirstName
  32.         cust.LastName = LastName
  33.         cust.AccountNumber = AccountNum
  34.  
  35.         ' When you use the InnerList.Add method, you must
  36.         ' pass it an object to add to the collection. In this
  37.         ' case we've created a new Customer object based on
  38.         ' passed parameters, and now we're adding it to the
  39.         ' InnerList.
  40.         Me.InnerList.Add(cust)
  41.  
  42.         Return cust
  43.  
  44.     End Function
  45.  
  46.     Public Overloads Function Item(ByVal Index As Integer) As Customer
  47.  
  48.         ' To retrieve an item from the InnerList, pass
  49.         ' the index of that item to the .Item property.
  50.  
  51.         Return CType(Me.InnerList.Item(Index), Customer)
  52.     End Function
  53.  
  54.     Public Overloads Function Item(ByVal cust As Customer) As Customer
  55.  
  56.         ' To retrieve an item from the InnerList, pass
  57.         ' the index of that item to the .Item property.
  58.  
  59.         Dim myIndex As Integer
  60.  
  61.         myIndex = Me.InnerList.IndexOf(cust)
  62.         Return CType(Me.InnerList.Item(myIndex), Customer)
  63.  
  64.     End Function
  65.  
  66.     Public Overloads Sub Remove(ByVal cust As Customer)
  67.  
  68.         ' To remove an item from the collection, you must
  69.         ' pass in a reference to that item (in this case, the
  70.         ' Customer object we want to remove).
  71.  
  72.         ' However, it is often more convenient to create a
  73.         ' Remove method that allows the calling code to pass in
  74.         ' only the index of the item instead of an object reference.
  75.         ' So we've overloaded the Remove method to use either one.
  76.         Me.InnerList.Remove(cust)
  77.     End Sub
  78.  
  79.     Public Overloads Sub Remove(ByVal Index As Integer)
  80.  
  81.         ' This is the second Remove method. Instead of passing
  82.         ' in an object reference, this Remove expects an index.
  83.  
  84.         ' The calling code can decide which one to call.
  85.  
  86.         ' If the calling code passes an index, you can simply
  87.         ' look up that item by using the InnerList.Item method,
  88.         ' then remove the item.
  89.  
  90.         Dim cust As Customer
  91.  
  92.         cust = CType(Me.InnerList.Item(Index), Customer)
  93.         If Not cust Is Nothing Then
  94.             Me.InnerList.Remove(cust)
  95.         End If
  96.     End Sub
  97.  
  98. End Class