Hi guys,

Just to clarify a point in the following documentation:
https://developers.google.com/protocol-buffers/docs/reference/csharp-generated#map

Map Fields

Each map field generates a read-only property of type 
Google.Protobuf.Collections.MapField<TKey, 
TValue> where TKey is the field's key type and TValue is the field's value 
type. For the most part, this acts like Dictionary<TKey, TValue>, but it 
has an additional Add overload to allow another dictionary to be added in 
one go. This is convenient when populating a repeated field in an object 
initializer. Additionally, MapField<TKey, TValue> has direct support for 
serialization, deserialization and cloning, but this is usually used by 
generated code instead of manually-written application code. Keys in the 
map are not permitted to be null; *values may be if the corresponding 
singular field type would support null values.*



https://developers.google.com/protocol-buffers/docs/reference/csharp/class/google/protobuf/collections/map-field-t-key-t-value-


*Null values are not permitted in the map, either for wrapper types or 
regular messages*. If a map is deserialized from a data stream and the 
value is missing from an entry, a default value is created instead. For 
primitive types, that is the regular default value (0, the empty string and 
so on); for message types, an empty instance of the message is created, as 
if the map entry contained a 0-length encoded value for the field.




My question is: Can the value in MapFields be null or not? The generated 
implementation prohibits it but I want to make sure that it is the case. 



Thanks

Tung


My apologies if someone else have already posted the same question. I was 
unable to search for an topic about this.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/8b2e372c-b223-46d6-84e8-39b5311cc938%40googlegroups.com.

Reply via email to