views:

174

answers:

1

I want to extend the VB.NET dictionary object to not bitch about an item being already in the associative array.

This is what i want to do:

    Public Class BetterDictionary
    Inherits System.Collections.Generic.Dictionary(Of Object, Object)

    Public Sub Store(ByRef key As Object, ByVal value As Object)
        If Me.ContainsKey(key) Then
            Me(key) = value
        Else
            Me.Add(key, value)
        End If
    End Sub

End Class

My problem now is: How can I replace the (of object, object) line to let the dictionary be of generic/customizable type?

+2  A: 

Define your inherited class as:

Public Class BetterDictionary(Of TKey,TValue)
    Inherits System.Collections.Generic.Dictionary(Of TKey, TValue)
Konamiman