Reflection and serialization are different:
Reflection: refers to the ability of a program to access, detect and modify its own state or behavior. Assemblies contain modules, and Modules contain types, which contain members. Reflection provides objects that encapsulate assemblies, modules, and types. You can dynamically create instances of types through reflection, bind types to existing objects, or obtain types from existing objects. Then you can call methods of the type or Access its fields and properties.
Reflection in c# is actually the dynamic use of class libraries, and classes and their members can be referenced by name.
# Serialization Serialization basically refers to saving an object to a file or stream. For example, the file can be serialized to save to Xml, or a disk file.
Serialization: Serialization is the process of converting objects into a format that is easy to transmit, such as binary, xml, and json for transmission over the network. The opposite of serialization is deserialization, which converts streams into objects, that is, the process of converting binary strings, XML, Json, etc. generated during the serialization process into data structures or objects. By combining the two processes of serialization and deserialization, data can be easily stored and transmitted.
What are serialization and deserialization?
We may often hear serialization and deserialization. In fact, in a more popular explanation, serialization is to save an object to a file or database field, and deserialization is to When appropriate, convert this file into the original object for use.
When two processes are communicating remotely, they can send various types of data to each other. No matter what type of data it is, it is transmitted over the network in the form of a binary sequence. The sender needs to convert this object into a byte sequence before it can be transmitted on the network; the receiver needs to restore the byte sequence into an object.
The process of converting an object into a byte sequence is called object serialization.
The process of restoring a byte sequence into an object is called deserialization of the object.
Common serialization methods:
1. BinaryFormatter
2. SoapFormatter
3. XML serialization
The above is the detailed content of What are reflection and serialization in c. For more information, please follow other related articles on the PHP Chinese website!