Note
If it is known that the collection implements only the supported generic interfaces, then for better performance use the generic TryAdd<T> overload if possible.
public static bool TryAdd(
this IEnumerable collection,
Object? item,
bool checkReadOnly = true,
bool throwError = true
)
<ExtensionAttribute>
Public Shared Function TryAdd (
collection As IEnumerable,
item As Object,
Optional checkReadOnly As Boolean = true,
Optional throwError As Boolean = true
) As Boolean
public:
[ExtensionAttribute]
static bool TryAdd(
IEnumerable^ collection,
Object^ item,
bool checkReadOnly = true,
bool throwError = true
)
[<ExtensionAttribute>]
static member TryAdd :
collection : IEnumerable *
item : Object *
?checkReadOnly : bool *
?throwError : bool
(* Defaults:
let _checkReadOnly = defaultArg checkReadOnly true
let _throwError = defaultArg throwError true
*)
-> bool
The item can be added to the collection if that is either an IList, IDictionary (when item is a DictionaryEntry instance), ICollectionT or IProducerConsumerCollectionT implementation.