c# - Why do I get warning CA2229 (Implement serialization constructors) when inheriting from standard type -
i have class definition this:
[serializable] public class mydictionary: dictionary<string, object> { }
however, code analysis warning:
ca2229 implement serialization constructors add constructor tcpfieldvaluedictionary following signature: 'protected tcpfieldvaluedictionary(serializationinfo info, streamingcontext context)'.
however, generic dictionary has constructor, public
modifier.
it easy add constructor (see below), why should done? advantage?
protected mydictionary(serializationinfo info, streamingcontext context) : base(info, context) { }
constructors aren't inherited. doesn't matter constructors base type has - if want constructor particular signature class, have implement one.
otherwise, default parameterless constructor.
Comments
Post a Comment