What's the difference between using "Serialize" or "DataContractAttribute" while you want to make a class seriallizable?
Compiler warns:
Type 'MyNAmeSpace.MyClass' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.
Why doesno't it suggest using [Serialize] attribute?
P.S. the class is not used for any web service. It's a normal class which I want to write to DB.


Bryian TanRank #396 · 6.3K reputationPosted Feb 15, 2017, 8:42 AM EST
Nilesh ShahRank #42 · 34.2K reputationPosted Feb 15, 2017, 9:06 AM EST
Bryian TanRank #396 · 6.3K reputationPosted Feb 15, 2017, 9:10 AM EST