检查 protoBuf 中是否存在消息类型

Check the presence of a message type in protoBuf

我是 gRPC 的新手,想检查 C# 语言中是否存在消息字段。我知道我们可以在 Java 中使用 hasField() 属性 但是在 C# 中没有提到任何这样的 属性。

message foo
{...}

message bar{
foo data=1;
}

如何查看消息栏中的数据字段是否已设置?

除非标记为 optional,字段 出现在每条消息中。

optional

data 中的字段(类型 foo)可能未设置,在这种情况下使用默认值。查看语言 guide.

NOTE Your question concerns protobufs (the messages that are sent) not gRPC (the RPC mechanism) specifically.