开发者

Is serializable attribute needed in concrete C# class?

开发者 https://www.devze.com 2023-01-25 07:52 出处:网络
In C#, consider we have a generic class and a concrete clas开发者_JAVA百科s [Serializable] public class GenericUser

In C#, consider we have a generic class and a concrete clas开发者_JAVA百科s

[Serializable]
public class GenericUser
{ ...

[Serializable]
public class ConcreteUser : GenericUser
{ ...

is it necessary to mark ConcreteUser as [Serializable] or inheritance will take care of it?


Inherited is set to false with the [AttributeUsage] of SerializableAttribute, so yes, you need to set it on the concrete class.

See http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx for more information.


you need to mark both, if both are to be binary serialized.

0

精彩评论

暂无评论...
验证码 换一张
取 消