【问题标题】:How do I add an enum using protobuf-net in VB.NET?如何在 VB.NET 中使用 protobuf-net 添加枚举?
【发布时间】:2015-09-24 23:45:39
【问题描述】:

我正在尝试创建一个遵循此结构的枚举:

Enum Foo
 Bar=0
 One=1
End Enum

我阅读了https://code.google.com/p/protobuf-net/wiki/Attributes 的文档,但我仍然不清楚如何添加枚举。我尝试在枚举上方添加<ProtoEnum(#)><ProtoMember(#)>,但出现错误“无法应用属性,因为该属性在此声明类型上无效”。

在 VB.NET 中使用 protobuf-net 向 Proto 文件添加枚举的正确语法是什么?

【问题讨论】:

    标签: vb.net enums protocol-buffers protobuf-net


    【解决方案1】:

    看到这么简单的语法问题,我总是觉得自己很笨:

    <ProtoContract()>
    Public Enum Foo
    
    '<ProtoMember(0)> I don't think <ProtoMember> is required inside an enum
    Bar = 0
    
    '<ProtoMember(1)>
    One = 1
    
    End Enum
    

    【讨论】:

      猜你喜欢
      • 2011-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多