Home > Backend Development > C#.Net Tutorial > What are reflection and serialization in c

What are reflection and serialization in c

anonymity
Release: 2020-09-15 10:59:08
Original
3777 people have browsed it

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.

What are reflection and serialization in c

# 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template