Google Protocol Buffers 使用3.0版本
下载protoc.exe
下载链接
https://github.com/protocolbuffers/protobuf/releases
阅读使用指南
https://developers.google.com/protocol-buffers/docs/csharptutorial
生成命令
protoc -I=. --csharp_out=. ./addressbook.proto
-I 输入当前目录 --csharp_out 输出目录
C# 类型映射
.proto TypeNotesC++ TypeJava TypePython Type[2]Go TypeRuby TypeC# TypePHP TypeDart Typedouble doubledoublefloatfloat64Floatdoublefloatdoublefloat floatfloatfloatfloat32Floatfloatfloatdoubleint32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32Fixnum or Bignum (as required)intintegerintint64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/long[3]int64Bignumlonginteger/string[5]Int64uint32Uses variable-length encoding.uint32int[1]int/long[3]uint32Fixnum or Bignum (as required)uintintegerintuint64Uses variable-length encoding.uint64long[1]int/long[3]uint64Bignumulonginteger/string[5]Int64sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32Fixnum or Bignum (as required)intintegerintsint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/long[3]int64Bignumlonginteger/string[5]Int64fixed32Always four bytes. More efficient than uint32 if values are often greater than 228.uint32int[1]int/long[3]uint32Fixnum or Bignum (as required)uintintegerintfixed64Always eight bytes. More efficient than uint64 if values are often greater than 256.uint64long[1]int/long[3]uint64Bignumulonginteger/string[5]Int64sfixed32Always four bytes.int32intintint32Fixnum or Bignum (as required)intintegerintsfixed64Always eight bytes.int64longint/long[3]int64Bignumlonginteger/string[5]Int64bool boolbooleanboolboolTrueClass/FalseClassboolbooleanboolstringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicode[4]stringString (UTF-8)stringstringStringbytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteString (ASCII-8BIT)ByteStringstringList<int>
转载于:https://www.cnblogs.com/ruxia/p/10225315.html
相关资源:数据结构—成绩单生成器