2009-12-01 84 views
1

我想将VB.NET字典对象扩展为不在关联数组中已经存在的项目。自定义字典对象?

这就是我想要做的:

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 

我现在的问题是:我怎么能代替行(对象,对象),让词典是通用/自定义类型的?

回答

3

定义你的继承类为:

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