NameObjectCollectionBase.BaseHasKeys Method tells whether the NameObjectCollectionBase instance contains entries whose keys are not Nothing.
Imports System
Imports System.Collections
Imports System.Collections.Specialized
Public Class MyCollection
Inherits NameObjectCollectionBase
Private _de As New DictionaryEntry()
Default Public ReadOnly Property Item(index As Integer) As DictionaryEntry
Get
_de.Key = Me.BaseGetKey(index)
_de.Value = Me.BaseGet(index)
Return _de
End Get
End Property
Public Sub New()
End Sub
Public Sub Add(key As [String], value As [Object])
Me.BaseAdd(key, value)
End Sub 'Add
Public ReadOnly Property HasKeys() As [Boolean]
Get
Return Me.BaseHasKeys()
End Get
End Property
End Class
Public Class SamplesNameObjectCollectionBase
Public Shared Sub Main()
Dim myCol As New MyCollection()
PrintKeysAndValues(myCol)
Console.WriteLine("HasKeys? {0}", myCol.HasKeys)
myCol.Add("b", "B")
PrintKeysAndValues(myCol)
Console.WriteLine("HasKeys? {0}", myCol.HasKeys)
End Sub
Public Shared Sub PrintKeysAndValues(myCol As MyCollection)
Dim i As Integer
For i = 0 To myCol.Count - 1
Console.WriteLine("[{0}] : {1}, {2}", i, myCol(i).Key, myCol(i).Value)
Next i
End Sub
End Class
Related examples in the same category