Share via


AdditionalPropertiesExtensions.TryAdd<T> Method

Definition

Attempts to add a property using the type name of the property as the key.

public static bool TryAdd<T>(this Microsoft.Extensions.AI.AdditionalPropertiesDictionary additionalProperties, T value);
static member TryAdd : Microsoft.Extensions.AI.AdditionalPropertiesDictionary * 'T -> bool
<Extension()>
Public Function TryAdd(Of T) (additionalProperties As AdditionalPropertiesDictionary, value As T) As Boolean

Type Parameters

T

The type of the property to add.

Parameters

additionalProperties
AdditionalPropertiesDictionary

The dictionary of additional properties.

value
T

The value to add.

Returns

true if the value was added successfully; false if the key already exists.

Remarks

This method uses the full name of the type parameter as the key. If the key already exists, the value is not updated and the method returns false.

Applies to