Reputation: 2753
if (settings.Contains("myDetailsObject"))
{
settings["myDetailsObject"] = myDetails;
}
else
{
settings.Add("myDetailsObject", myDetails);
}
settings.Save();
Tried doing the below, however it gave me error. those save values are in strings and is a custom object. tried even saving an integer instead and is still not working
Type 'SharedLibary.Object.MyDetailsObject' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
Upvotes: 0
Views: 323
Reputation: 8126
Mark class with [DataContractAttribute]
attribute and all members that you want to serialize with [DataMemberAttribute]
. Note, that marked properties must be public
.
Also, don't forget to add reference to System.Runtime.Serialization
Upvotes: 1
Reputation: 455
Add the attribute [DataMember] on all properties that you want to serialize in your MyDetailsObject class.
Upvotes: 4