Does Marking Objects As Serializable Incur Overhea

2020-07-06 03:06发布

If I add the [Serializable] attribute to a class, does this introduce any overhead? How about if the class is never used in any serialization operations?

标签: c# .net
1条回答
老娘就宠你
2楼-- · 2020-07-06 03:28

This doesn't add any overhead to the normal runtime use of the object.

Marking a class as Serializable doesn't even result in a size difference in metadata. It just sets a bit in the typedef flag. (Thanks to thecoop for pointing that out)

查看更多
登录 后发表回答