简体   繁体   English

我可以访问未序列化的内部类吗

[英]Can i access the Inner Class which is not serialized

I am having a class Which implements serializable interface, it has one inner class which is not implementing serializable interface. 我有一个实现可序列化接口的类,它有一个不实现可序列化接口的内​​部类。

So Can i access the content of inner class at the receiver. 因此,我可以在接收方访问内部类的内容吗?

Thanks in advance. 提前致谢。

If the inner class doesn't implement Serializable , it cannot be serialized. 如果内部类未实现Serializable ,则无法对其进行序列化。 Any attempt to do so would throw NotSerializableException at the sender. 任何尝试这样做都会在发送方抛出NotSerializableException As you would have discovered yourself when you tried it. 就像您在尝试时会发现自己一样。

The answer is No. Any data you expect as receiver need serialization. 答案是否定的。您希望作为接收器的任何数据都需要序列化。 Inner class must implement ISerializable. 内部类必须实现ISerializable。

it has one inner class which is not implementing serializable interface. 它有一个内部类,它没有实现可序列化的接口。 So Can i access the content of inner class at the receiver. 因此,我可以在接收方访问内部类的内容吗?

No. If it is not marked as Serializable , it can't be serialized. 否。如果未标记为Serializable ,则无法序列化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何判断 class 是否可以序列化? - How do I tell if a class can be serialized? 测试是否可以序列化类 - Test if a class can be serialized Can I create a static class of outer class and use an inner static class as the category of outer class to access to specific methods? - Can I create a static class of outer class and use an inner static class as the category of outer class to access to specific methods? 检查二进制序列化数据是否与序列化数据的类匹配 - Check whether binary serialized data matches the class which serialized it 静态构造函数的类可以序列化吗? - can a class with static constructor serialized? 没有类模型可以序列化到ViewModel中 - No class model can be serialized into the ViewModel 如何扩展表单类以访问全局变量,而不必指定它属于哪个类? - How can I extend a form class to access global variables without having to specify which class it belongs to? 如何使用抽象基类继承内部类? - How can I inherit an inner class using an abstract base class? 如何更新由自定义对象序列化的xml文件中的属性值? - How can I update the property value in xml file which was serialized by custom object? 如何重命名序列化为XML但继续支持以前名称的枚举? - How can I rename an enum which is serialized to XML but continue to support previous names?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM