• <tfoot id='zEWH9'></tfoot>

    1. <small id='zEWH9'></small><noframes id='zEWH9'>

        <bdo id='zEWH9'></bdo><ul id='zEWH9'></ul>

      1. <legend id='zEWH9'><style id='zEWH9'><dir id='zEWH9'><q id='zEWH9'></q></dir></style></legend>

        <i id='zEWH9'><tr id='zEWH9'><dt id='zEWH9'><q id='zEWH9'><span id='zEWH9'><b id='zEWH9'><form id='zEWH9'><ins id='zEWH9'></ins><ul id='zEWH9'></ul><sub id='zEWH9'></sub></form><legend id='zEWH9'></legend><bdo id='zEWH9'><pre id='zEWH9'><center id='zEWH9'></center></pre></bdo></b><th id='zEWH9'></th></span></q></dt></tr></i><div id='zEWH9'><tfoot id='zEWH9'></tfoot><dl id='zEWH9'><fieldset id='zEWH9'></fieldset></dl></div>

        为什么必须用属性 [serializable] 标记一个类?

        Why do you have to mark a class with the attribute [serializable]?(为什么必须用属性 [serializable] 标记一个类?)
          <bdo id='MaTyS'></bdo><ul id='MaTyS'></ul>

              <tfoot id='MaTyS'></tfoot>
                <legend id='MaTyS'><style id='MaTyS'><dir id='MaTyS'><q id='MaTyS'></q></dir></style></legend>
                    <tbody id='MaTyS'></tbody>

                  <small id='MaTyS'></small><noframes id='MaTyS'>

                  <i id='MaTyS'><tr id='MaTyS'><dt id='MaTyS'><q id='MaTyS'><span id='MaTyS'><b id='MaTyS'><form id='MaTyS'><ins id='MaTyS'></ins><ul id='MaTyS'></ul><sub id='MaTyS'></sub></form><legend id='MaTyS'></legend><bdo id='MaTyS'><pre id='MaTyS'><center id='MaTyS'></center></pre></bdo></b><th id='MaTyS'></th></span></q></dt></tr></i><div id='MaTyS'><tfoot id='MaTyS'></tfoot><dl id='MaTyS'><fieldset id='MaTyS'></fieldset></dl></div>

                1. 本文介绍了为什么必须用属性 [serializable] 标记一个类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您可以将任何文档转换为字节数组并将其保存到磁盘,然后将文件重建为其原始形式(只要您有文件名的元数据等).

                  Seeing as you can convert any document to a byte array and save it to disk, and then rebuild the file to its original form (as long as you have meta data for its filename etc.).

                  为什么你必须用 [Serializable] 等标记一个类?这与元数据"类型信息是否相同,因此当您将对象转换为其类时,事情会正确映射?

                  Why do you have to mark a class with [Serializable] etc? Is that just the same idea, "meta data" type information so when you cast the object to its class things are mapped properly?

                  推荐答案

                  首先,你没有.

                  它只是一个 标记接口,它告诉序列化程序该类由以下项组成它可以序列化(可能是也可能不是),也就是可以使用默认的序列化.

                  It is simply a marker interface that tells the serializer that the class is composed of items that it can serialize (which may or may not be true) and that is can use the default serialization.

                  XMLSerializer 有额外的要求,即类的构造函数为零参数.

                  The XMLSerializer has the additional requirement to have a zero parameter constructor to the class.

                  还有其他使用序列化合同的序列化程序(例如 DataContractSerializer) - 与简单地将类标记为 Serializable 相比,它们可以让您更好地控制序列化.您还可以通过实现 ISerializable 来获得更多控制权 接口.

                  There are other serializers that use contracts for serialization (such as the DataContractSerializer) - they give you more control over serialization than simply marking a class as Serializable. You can also get more control by implementing the ISerializable interface.

                  这篇关于为什么必须用属性 [serializable] 标记一个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  How can I force the PropertyGrid to show a custom dialog for a specific property?(如何强制 PropertyGrid 显示特定属性的自定义对话框?)
                  Associate attribute with code generated property in .net(将属性与 .net 中的代码生成属性相关联)

                    <small id='LWqWP'></small><noframes id='LWqWP'>

                  • <legend id='LWqWP'><style id='LWqWP'><dir id='LWqWP'><q id='LWqWP'></q></dir></style></legend>
                    <tfoot id='LWqWP'></tfoot>
                    • <i id='LWqWP'><tr id='LWqWP'><dt id='LWqWP'><q id='LWqWP'><span id='LWqWP'><b id='LWqWP'><form id='LWqWP'><ins id='LWqWP'></ins><ul id='LWqWP'></ul><sub id='LWqWP'></sub></form><legend id='LWqWP'></legend><bdo id='LWqWP'><pre id='LWqWP'><center id='LWqWP'></center></pre></bdo></b><th id='LWqWP'></th></span></q></dt></tr></i><div id='LWqWP'><tfoot id='LWqWP'></tfoot><dl id='LWqWP'><fieldset id='LWqWP'></fieldset></dl></div>
                        <tbody id='LWqWP'></tbody>

                      • <bdo id='LWqWP'></bdo><ul id='LWqWP'></ul>