ConditionalWeakTable<TKey,TValue>.AddOrUpdate(TKey, TValue) 方法

定义

如果键不存在,则添加键和值,或如果其不存在,则更新现有键的值。Adds the key and value if the key doesn't exist, or updates the existing key's value if it does exist.

public:
 void AddOrUpdate(TKey key, TValue value);
public void AddOrUpdate (TKey key, TValue value);
member this.AddOrUpdate : 'Key * 'Value -> unit
Public Sub AddOrUpdate (key As TKey, value As TValue)

参数

key
TKey

要添加或更新的键。The key to add or update. 可能不为 nullMay not be null.

value
TValue

要与 key 关联的值。The value to associate with key.

例外

keynullkey is null.

适用于