开发者

Is serializable attribute needed in concrete C# class?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜