
The example demonstrates that the Add method throws an ArgumentException when attempting to add a duplicate key.
#Add dictionary to list of dictionaries python code#
The following code example creates an empty Dictionary of strings with string keys and uses the Add method to add some elements. ICollection> IDictionary IEnumerable> IEnumerable IReadOnl圜ollection> IReadOnlyDictionary ICollection IDictionary IEnumerable IDeserializationCallback ISerializable Examples Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDeserializationCallback, IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue)), ISerializable Type Parameters Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDeserializationCallback, IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnl圜ollection(Of KeyValuePair(Of TKey, TValue)), IReadOnlyDictionary(Of TKey, TValue), ISerializable Public Class Dictionary(Of TKey, TValue) Implements ICollection(Of KeyValuePair(Of TKey, TValue)), IDictionary, IDictionary(Of TKey, TValue), IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnl圜ollection(Of KeyValuePair(Of TKey, TValue)), IReadOnlyDictionary(Of TKey, TValue) Public Class Dictionary(Of TKey, TValue) Interface IReadOnl圜ollection> Public Class Dictionary(Of TKey, TValue) Interface IDeserializationCallback type Dictionary = class Interface IDictionary type Dictionary = class Public class Dictionary : >,, >, 圜ollection>,, ,, type Dictionary = class Public ref class Dictionary : System::Collections::Generic::ICollection>, System::Collections::Generic::IDictionary, System::Collections::Generic::IEnumerable>, System::Collections::IDictionary, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable public class Dictionary : >,, >, 圜ollection>,, public class Dictionary : >,, >, 圜ollection>,, ,, Public ref class Dictionary : System::Collections::Generic::ICollection>, System::Collections::Generic::IDictionary, System::Collections::Generic::IEnumerable>, System::Collections::Generic::IReadOnl圜ollection>, System::Collections::Generic::IReadOnlyDictionary, System::Collections::IDictionary, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable generic

Public ref class Dictionary : System::Collections::Generic::ICollection>, System::Collections::Generic::IDictionary, System::Collections::Generic::IEnumerable>, System::Collections::Generic::IReadOnl圜ollection>, System::Collections::Generic::IReadOnlyDictionary, System::Collections::IDictionary generic


Represents a collection of keys and values.
