OrderedDictionary<TKey,TValue>.TryAdd(TKey, TValue) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified key and value to the dictionary if the key doesn't already exist.
public:
bool TryAdd(TKey key, TValue value);
public bool TryAdd (TKey key, TValue value);
member this.TryAdd : 'Key * 'Value -> bool
Public Function TryAdd (key As TKey, value As TValue) As Boolean
Parameters
- key
- TKey
The key of the element to add.
- value
- TValue
The value of the element to add. The value can be null
for reference types.
Returns
true
if the key didn't exist and the key and value were added to the dictionary; otherwise, false
.
Exceptions
key is null
.
Applies to
Samarbeid med oss på GitHub
Du finner kilden for dette innholdet på GitHub. Der du også kan opprette og se gjennom problemer og pull-forespørsler. Hvis du vil ha mer informasjon, kan du se vår bidragsyterveiledning.