CommandStateTryAdd Method

Attempts to add the specified key and value to the CommandState without overwriting an existing entry.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
public bool TryAdd(
	string key,
	Object? value
)

Parameters

key  String
The key of the element to add.
value  Object
The value of the element to add.

Return Value

Boolean
if the key and value pair was added to the CommandState successfully; otherwise, .

Remarks

Unlike the Add method, this method doesn't throw an exception if the element with the given key exists in the CommandState. Unlike the indexer, TryAdd doesn't override the element if the element with the given key exists in the dictionary. If the key already exists, TryAdd does nothing and returns .

Exceptions

See Also