是否添加[Serializable接口]对类有任何性能影响? [英] Does adding [Serializable] to the class have any performance implications?

查看:945
本文介绍了是否添加[Serializable接口]对类有任何性能影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在[Serializable]属性添加到一个类,是非常影响性能。

I need to add the [Serializable] attribute to a class that is extremely performance sensitive.

请问这个属性对类的操作的任何性能影响?

Will this attribute have any performance implications on the operation of the class?

推荐答案

当他们第一次访问时才创建的属性类的实例。如果你不这样做在那个特定类的系列化, SerializableAttribute()构造函数将永远不会被调用,因此它不会造成任何性能问题。

Instances of attribute classes are only created when they're first accessed. If you don't do any serialization on that particular class, the SerializableAttribute() constructor will never be called, hence it won't cause any performance issues.

下面是关于属性构造一个有趣的文章:
<一href=\"http://www.codingonthetrain.com/2008/10/attribute-constructors.html\">http://www.codingonthetrain.com/2008/10/attribute-constructors.html

Here's an interesting article about attribute constructors: http://www.codingonthetrain.com/2008/10/attribute-constructors.html

这篇关于是否添加[Serializable接口]对类有任何性能影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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