NameObjectCollectionBase.BaseSet Method sets the value of the entry at the specified index
Imports System Imports System.Collections Imports System.Collections.Specialized Public Class MyCollection Inherits NameObjectCollectionBase Default Public Property Item(index As Integer) As [Object] Get Return Me.BaseGet(index) End Get Set Me.BaseSet(index, value) End Set End Property Default Public Property Item(key As [String]) As [Object] Get Return Me.BaseGet(key) End Get Set Me.BaseSet(key, value) End Set End Property Public ReadOnly Property AllKeys() As [String]() Get Return Me.BaseGetAllKeys() End Get End Property Public Sub New(d As IDictionary) Dim de As DictionaryEntry For Each de In d Me.BaseAdd(CType(de.Key, [String]), de.Value) Next de End Sub End Class Public Class SamplesNameObjectCollectionBase Public Shared Sub Main() Dim d = New ListDictionary() d.Add("A", "a") d.Add("B", "b") d.Add("P", "p") Dim myCol As New MyCollection(d) PrintKeysAndValues2(myCol) Console.WriteLine() myCol(1) = "AAAAA" PrintKeysAndValues2(myCol) Console.WriteLine() myCol("A") = "QQQQQ" PrintKeysAndValues2(myCol) End Sub Public Shared Sub PrintKeysAndValues2(myCol As MyCollection) Dim s As [String] For Each s In myCol.AllKeys Console.WriteLine("{0}, {1}", s, myCol(s)) Next s End Sub End Class