开发者

Custom dictionary object?

开发者 https://www.devze.com 2022-12-13 09:46 出处:网络
I want to extend the VB.NET dictionary object to not bitch about an item being already in the associative array.

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?


Define your inherited class as:

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

精彩评论

暂无评论...
验证码 换一张
取 消