<PackageReference Include="Google.Protobuf" Version="3.34.2" />

Google.Protobuf.Collections.MapField<TKey, TValue>

public sealed class MapField<TKey, TValue> : IDeepCloneable<MapField<TKey, TValue>>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IEquatable<MapField<TKey, TValue>>, IDictionary, ICollection, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>
Representation of a map field in a Protocol Buffer message.
public sealed class Codec<TKey, TValue>

A codec for a specific map field. This contains all the information required to encode and decode the nested messages.

public int Count { get; }

Gets the number of elements contained in the map.

public bool IsReadOnly { get; }

Gets a value indicating whether the map is read-only.

public TValue this[TKey key] { get; set; }

Gets or sets the value associated with the specified key.

public ICollection<TKey> Keys { get; }

Gets a collection containing the keys in the map.

public ICollection<TValue> Values { get; }

Gets a collection containing the values in the map.

public MapField()

public void Add(TKey key, TValue value)

Adds the specified key/value pair to the map.

public void Add(IDictionary<TKey, TValue> entries)

Adds the specified entries to the map. The keys and values are not automatically cloned.

public void AddEntriesFrom(CodedInputStream input, Codec<TKey, TValue> codec)

public void AddEntriesFrom(ref ParseContext ctx, Codec<TKey, TValue> codec)

public int CalculateSize(Codec<TKey, TValue> codec)

public void Clear()

Removes all items from the map.

public MapField<TKey, TValue> Clone()

Creates a deep clone of this object.

public bool ContainsKey(TKey key)

Determines whether the specified key is present in the map.

public bool Equals(MapField<TKey, TValue> other)

Compares this map with another for equality.

public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()

Returns an enumerator that iterates through the collection.

public void MergeFrom(IDictionary<TKey, TValue> entries)

Adds the specified entries to the map, replacing any existing entries with the same keys. The keys and values are not automatically cloned.

public bool Remove(TKey key)

Removes the entry identified by the given key from the map.

public bool TryGetValue(TKey key, out TValue value)

Gets the value associated with the specified key.

public void WriteTo(CodedOutputStream output, Codec<TKey, TValue> codec)

public void WriteTo(ref WriteContext ctx, Codec<TKey, TValue> codec)