Protobuf Maps and Dictionaries
Learn how to use maps in Protobuf and their translation to C#.
We'll cover the following
As well as dealing with collections, Protobuf can deal with dictionary-like structures. A dictionary (also known as a map) is a data structure that stores a collection of key-value pairs. Because the retrieval of entries is done via the key, each key must be unique.
In C#, the most common way to implement this functionality is via the Dictionary<Tkey, TValue>
class from the System.Collections.Generic
namespace. In Protobuf, this is achieved via the map<key, value>
data type, which we will examine next.
Using map
in Protobuf
The following interactive code editor contains the setup with both the gRPC client and server applications we built previously. We'll use it to add some new functionality and see how it works.
Get hands-on with 1400+ tech skills courses.