This is not a question, but something more than the thought I recently had. I take the XmlAttribute for the XmlSerialize class as an example: you can set the attributes for the class to choose which properties should be serialized, but the same thing can be done quite simply by implementing the theoretical IXmlSerializable interface (it exists something similar, I don’t remember) and overloading the Serialize method for this class, which simply calls Serialize the properties you want to serialize (this.myProp1.Serialize ()), is the same for Deserialize
So, what I'm basically saying is, is the attribute method a bit redundant? (I like it, but I don’t think it is logically different from the interface)
Thanks for any answer, as I said it was just a thought ... hope someone finds this interesting
Update 1: It’s good that I incorrectly explained that I was asking: “Why should I choose an attribute instead of an interface (or vice versa)”, and not this particular case (I took serialization, because this is the first thing that appeared in my mind) thank you for the answer, by the way, because they are very interesting
source
share