Google Protocol Buffers is a protocol generation tool produced by Google, which is cross-platform, efficient, and fast, which is very helpful for our own program definition and use of private protocols.
I read many articles on the Internet, and I feel that they are all nonsense, reprinted by JX!!
They are all very old articles, and then copy and paste, and find that many people have a characteristic, and they feel that they are very advanced articles, so they like to copy and paste without practicing them!!
First: First, we prepare a .proto file, following Google's format message, the name of a class required field, I found a random file from the Internet, as follows:
Second: Download the package with nuget with the following command:
Third: Find the location of the package in your project folder, as follows:
C:\项目文件夹\packages\Google.ProtocolBuffers.2.4.1.555\tools My location is: C:\project\MyProjects\Study\packages\Google.ProtocolBuffers.2.4.1.555\tools
Fourth: Copy the ProtoMyRequest.proto file to the tools folder and execute the following commands:
A CS file is then generated and copied to the project!!
Recompile, via! No errors! In the next lesson, let's talk about how to use it.
|