服务说明是必需的

编程入门 行业动态 更新时间:2024-10-13 00:30:41
本文介绍了服务说明是必需的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

什么是序列化?以及如何实施?任何人都可以借助最好理解的例子来解释它吗?

What is serialization? and how it can be implemented? can anyone explain it with help of best understandable example?

推荐答案

序列化是将在内存中表示的对象转换为平面格式的过程。通常以文本格式或字节数组存储。 序列化需要双向 - 允许读者从平面格式重新创建对象。 例如: serialization is the process of translating an object that is represented in memory, into a "flat" format that can be stored, usually in a text format, or a byte array. the serialization needs to be two way- to allow a reader to recreate the object from the flat format. for example: int number = 5; string serializedText = SomeSerializationUtility.SerializeToString(number); int number2 = SomeSerializationUtility.DeserializeFromString(serializedText ); Asset.AreEqual(number, number2);

当然,序列化时事情变得复杂得多具有多个属性和内部状态的对象,以及可能本身就是复杂类型的内部属性。 所以例如:

of course things get a lot more complicated when serializing objects that have multiple properties, and internal states, and perhaps inner properties that are themselves complex types. so for example:

public class MyData { public string Text; public int Number; public List<double> data; } </double>

可以用以下XML格式表示:

could be represented in the following XML format:

<mydata> <text type="string">blabla</text> <number type="int">5</number> <data type="List<double>"><item>0.0</item></data> </mydata>

你应该能够很容易地看到这些数据是如何在XML元素和类属性之间映射的。

and you should be able to easily see how this data is mapped between XML elements and class properties.

我认为你应该尝试阅读像 this [ ^ ]。 很好的例子。 快乐编码。 I think that you should try reading something like this[^] on MSDN. Nice example there. Happy coding.

更多推荐

服务说明是必需的

本文发布于:2023-10-31 13:38:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546245.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!