DictionaryBase.OnGet 方法

获取 DictionaryBase 实例中带有指定键和值的元素。

**命名空间:**System.Collections
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Protected Overridable Function OnGet ( _
    key As Object, _
    currentValue As Object _
) As Object
用法
Dim key As Object
Dim currentValue As Object
Dim returnValue As Object

returnValue = Me.OnGet(key, currentValue)
protected virtual Object OnGet (
    Object key,
    Object currentValue
)
protected:
virtual Object^ OnGet (
    Object^ key, 
    Object^ currentValue
)
protected Object OnGet (
    Object key, 
    Object currentValue
)
protected function OnGet (
    key : Object, 
    currentValue : Object
) : Object

参数

  • key
    要获取的元素的键。
  • currentValue
    与 key 相关联的元素的当前值。

返回值

包含带有指定键和值的元素的 Object

备注

该方法的默认实现返回 currentValue。这是为了由派生类重写,以便在检索指定元素时执行其他操作。

仅对 Dictionary 属性所返回的实例调用 On* 方法,而不对 InnerHashtable 属性所返回的实例调用这些方法。

此方法的默认实现的运算复杂度为 O(1)。

给实现者的说明 此方法允许实施者定义当执行基础 System.Collections.Hashtable 的标准“获取”(Get) 行为时必须执行的进程。通过定义此方法,实施者可以向继承方法添加功能,而无须重写所有其他方法。 OnGet 可用于指定在返回从基础 System.Collections.Hashtable 检索的值之前执行的进程。例如,实施者可在返回某个值之前将该值转换为另一种类型。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

DictionaryBase 类
DictionaryBase 成员
System.Collections 命名空间