Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

TryAdd

abstract virtual func TryAdd(key: K, value: V) -> bool

Declaring type: MutableMap<K, V>
Module: System.Collections
Assembly: System.Runtime.dll
Source file: MutableMap.rvn

Defined by MutableMap<K, V>.TryAdd · Required implementation (no default).

Interface implementation: Required implementation (no default).

Inserts the key and value only when the key is absent; returns false without replacing an existing entry.

Parameters

Name Type Description
key K The key to look up or update.
value V The value on which this operation acts.

Return value

Boolean

True if a new entry was inserted; false if the key already existed.