Protobuf 中可空类型、日期时间类型及空消息的使用
1. 使用 Protobuf 中的可空类型
在 Protobuf 的消息定义中,我们可以使用可空类型。通过将 HelloReply 消息的内容替换为以下内容,我们可以使用所有可用的类型:
message HelloReply {
google.protobuf.StringValue message = 1;
google.protobuf.UInt32Value message_processed_count = 2;
google.protobuf.UInt64Value message_length_in_bytes = 3;
google.protobuf.Int32Value message_length_in_letters = 4;
google.protobuf.Int64Value milliseconds_to_deadline = 5;
google.protobuf.FloatValue seconds_to_deadline = 6;
google.protobuf.DoubleValue minutes_to_deadline = 7;
google.protobuf.BoolValue last_name_present = 8;
google.protobuf.BytesValue message_bytes = 9;
}
现在,我们为 Protobuf 定义添加了所有包装字段的表示。接下来,我们可以构建应用程序,查看这些字段在 C# 中的表示
超级会员免费看
订阅专栏 解锁全文
1801

被折叠的 条评论
为什么被折叠?



