20、Protobuf 中可空类型、日期时间类型及空消息的使用

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# 中的表示

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值