什么是c#中的序列化和反序列化 [英] What is serialization and deserialization in c#

查看:68
本文介绍了什么是c#中的序列化和反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





什么是c#中的序列化和反序列化?

任何人都可以描述我的详细信息以及它的好处。< br $>


问候,

Purnananda Behera

Hi,

What is serialization and deserialization in c#?
Can anybody describe me details and what its benifit to use.

Regards,
Purnananda Behera

推荐答案

您可以定义序列化和反序列化以下面的方式

序列化意味着(将对象实例转换为XML文档)



反序列化意味着(将XML文档转换为对象)实例)



除了XML,您还可以使用JSON,二进制文本,文本等。



见这个

http://msdn.microsoft.com/en-us/library /ms731073.aspx [ ^ ]



ASP.NET中的序列化和反序列化C# [ ^ ]



http://sharpertutorials.com/serialization/ [ ^ ]
You can define serialization and deserialization in the below manner
Serialize means (convert an object instance to an XML document)

Deserialize means (convert an XML document into an object instance)

Instead of XML you can also go with JSON, binary, text etc.

see this
http://msdn.microsoft.com/en-us/library/ms731073.aspx[^]

Serialization and Deserialization in ASP.NET with C#[^]

http://sharpertutorials.com/serialization/[^]


序列化是从对象的内存表示中进行的过程基于磁盘的格式,可以是二进制,JSON,BSON,XML等任何形式。



反序列化是一个相反的过程,在这个过程中你得到一个对象基于磁盘的格式。



这主要用于文档存储,ORM样式数据库,存储配置文件等。



主要好处是填充对象的速度,而不是在数据库存储的情况下查询多个表。



编码的简单性是另一个好处,因为你不需要知道表格列等
Serialization is the process of going from in memory representation of an object to a disk based format which can be in any form like binary, JSON, BSON, XML, etc.

Deserialization is the reverse process, in which you get an object from the disk based format.

This is mainly used in document store, ORM style databases, storing config files etc.

The main benefit is the speed in populating an object as opposed to querying multiple tables in the case of database storage.

Simplicity in coding is another benefit, as you don't need to know tables columns etc.


'序列化'是保存/保存对象或数据的结构和/或状态。您保存的目标可能是在内存中,硬盘上,或通过互联网协议或其他协议,到本地或远程数据库,服务器,NAS等。



'反序列化'是从上面列出的保存相同类型的存储读回:通过设置属性,字段等来刷新现有对象的状态。或者您可以'反序列化'完全重新创建类,用户界面和代码,类的实例,属性值,字段等。



序列化和反序列化(S& D )可以使用各种格式,其中一些格式是.NET内置的。 .NET中的类可以通过在某些指导原则中使用属性标记为可序列化。



我们可以说低级别(字节串:即二进制)S& D格式,我们可以说高级格式,这些格式有些人类可读,如XML和JSON。



建议:采取看一下Mehdi Gholam目前的JSON序列化器和反序列化器,fastJSON[ ^ ],在CodeProject上,可以看到对S& D使用高级格式的最新实现。
'Serialization' is the saving/preservation of the 'structure' and/or 'state' of objects, or data. The target that you 'save' to may be in memory, on a hard-disk, or by internet protocols, or other protocols, to a local or remote database, server, NAS, etc.

'Deserialization' is the reading back in from the same types of storage you 'saved' to listed above to: refresh the state of existing objects by setting their properties, field, etc. Or you may 'deserialize' to completely re-create classes, user interfaces, and code, instances of classes, values for properties, fields, etc.

Both Serialization and Deserialization (S&D) can utilize a wide variety of formats, some of which are built-in to .NET. Classes in .NET can be marked as 'serializable' via the use of 'Attributes' within certain guidelines.

We can speak of low-level (bunch of bytes: i.e., binary) S&D formats, and we can speak of 'high-level' formats which are somewhat human readable such as XML and JSON.

Suggestion: take a look at Mehdi Gholam's current JSON serializer and de-serializer, "fastJSON"[^], here on CodeProject to see a state-of-the-art implementation of use of a 'high-level' format for S&D.


这篇关于什么是c#中的序列化和反序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆