C# 使用Google Protocol Buffers
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 Type | Notes | C++ Type | Java Type | Python Type[2] | Go Type | Ruby Type | C# Type | PHP Type | Dart Type |
|---|---|---|---|---|---|---|---|---|---|
| double | double | double | float | float64 | Float | double | float | double | |
| float | float | float | float | float32 | Float | float | float | double | |
| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | Fixnum or Bignum (as required) | int | integer | int |
| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long[3] | int64 | Bignum | long | integer/string[5] | Int64 |
| uint32 | Uses variable-length encoding. | uint32 | int[1] | int/long[3] | uint32 | Fixnum or Bignum (as required) | uint | integer | int |
| uint64 | Uses variable-length encoding. | uint64 | long[1] | int/long[3] | uint64 | Bignum | ulong | integer/string[5] | Int64 |
| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | Fixnum or Bignum (as required) | int | integer | int |
| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long[3] | int64 | Bignum | long | integer/string[5] | Int64 |
| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 228. | uint32 | int[1] | int/long[3] | uint32 | Fixnum or Bignum (as required) | uint | integer | int |
| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 256. | uint64 | long[1] | int/long[3] | uint64 | Bignum | ulong | integer/string[5] | Int64 |
| sfixed32 | Always four bytes. | int32 | int | int | int32 | Fixnum or Bignum (as required) | int | integer | int |
| sfixed64 | Always eight bytes. | int64 | long | int/long[3] | int64 | Bignum | long | integer/string[5] | Int64 |
| bool | bool | boolean | bool | bool | TrueClass/FalseClass | bool | boolean | bool | |
| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode[4] | string | String (UTF-8) | string | string | String |
| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | String (ASCII-8BIT) | ByteString | string | List<int> |
C# 使用Google Protocol Buffers的更多相关文章
- Google Protocol Buffers 入门
Google Protocol Buffers 是一种轻便高效的结构化数据存储格式,可以用于结构化数据串行化,或者说序列化.它很适合做数据存储或 RPC 数据交换格式.可用于通讯协议.数据存储等领域的 ...
- Google Protocol Buffers介绍
简要介绍和总结protobuf的一些关键点,从我之前做的ppt里摘录而成,希望能节省protobuf初学者的入门时间.这是一个简单的Demo. Protobuf 简介 Protobuf全称Google ...
- Google Protocol Buffers 快速入门(带生成C#源码的方法)
Google Protocol Buffers是google出品的一个协议生成工具,特点就是跨平台,效率高,速度快,对我们自己的程序定义和使用私有协议很有帮助. Protocol Buffers入门: ...
- Google Protocol Buffers简介
什么是 protocol buffers ? Protocol buffers 是一种灵活.高效的序列化结构数据的自动机制--想想XML,但是它更小,更快,更简单.你只需要把你需要怎样结构化你的数据定 ...
- Google Protocol Buffers 反序列化 转
http://www.cnblogs.com/royenhome/archive/2010/10/30/1865256.html 本文作为结束篇,会稍微介绍下怎么反序列化GoogleBuffer数 ...
- Google Protocol Buffers和java字符串处理控制
大多数的操作码被从夜晚复制.懒得敲. 直接在源代码和测试结果如下. serabuffer.proto档.使用下面的命令来生成java代码. protoc -I=./ --java_out=./ ser ...
- DELPHI、FLASH、AS3、FLEX使用Protobuf(google Protocol Buffers)的具体方法
最近因为工作需要,需要在不同的开发环境中应用Protobuf,特此,我专门研究了一下.为了防止自己忘记这些事情,现在记录在这里!需要的朋友可以借鉴一些,因为这些东西在GOOGLE和百度上搜索起来真的很 ...
- Google Protocol Buffers学习
参考资料:http://www.cnblogs.com/royenhome/archive/2010/10/29/1864860.html 参考资料:http://www.jianshu.com/p/ ...
- 阅读Google Protocol Buffers 指南,整理pb语法
官方网站: https://developers.google.com/protocol-buffers/docs/proto3 1.简单定义一个Message 类型 pb语法文件以"*.p ...
随机推荐
- android Run模式也会出现"Waiting for debugger"的解决方法
android Run模式也会出现"Waiting for debugger"的解决方法 出现“waiting for debugger”窗口是在debug模式下运行出现的.但是, ...
- Python常见错误:IndexError: list index out of range
用python写脚本查询字典时,在遍历字典时循环到某一项时老是报错 出现这种错误有两种情况: 第1种可能情况 list[index]index超出范围 第2种可能情况 list是空值就会出现 In ...
- [C#]“正在终止线程”的问题
在C#中启用线程后,如果试图使用Abort方法来终止线程,那么必定会抛出“正在终止线程”的异常,一开始我也想过如何来避免这种异常出现,花了不少气力,但最后发现全是徒劳. 原因是一个正在运行的线程被终止 ...
- hdu6069 多校Counting Divisors
思路:对于n^k其实就是每个因子的个数乘了一个K.然后现在就变成了求每个数的每个质因子有多少个,但是比赛的时候只想到sqrt(n)的分解方法,总复杂度爆炸,就一直没过去,然后赛后看官方题解感觉好妙啊! ...
- windows socket扩展函数
1.AcceptEx() AcceptEx()用于异步接收连接,可以取得客户程序发送的第一块数据. BOOL AcceptEx( _In_ SOCKET sListenSocket, ...
- 轮询、中断、DMA和通道
from http://blog.csdn.net/lastsweetop/article/details/3418769 一.轮询方式 对I/O设备的程序轮询的方式,是早期的计算机系统对I/O设备的 ...
- TortoiseGit disconnected no supported authentication
从远程服务器上获取到的工程,用Git没问题,而TortoiseGit报错: Disconnected: No supported authentication methods available(se ...
- 2.2.10数据类型String的常量池特性
在JVM中具有String常量池缓存的功能 package com.cky.test; /** * Created by edison on 2017/12/8. */ public class Te ...
- iOS程序的执行顺序 和 UIViewController的生命周期
iOS程序的执行顺序 1 进入程序的入口 进入main函数, 设置AppDelegate称为函数的代理 2 程序完成加载 -[AppDelegate application:didFinishLau ...
- 手机开发-Android
Android 语言.JAVA 开发环境.一是JDKjava开发工具包,二是eclipse开发工具IDE,三是Android SDK安卓软件开发包,四是ADT Android开发工具把JDK和Andr ...