问题
I was looking for something like this:
...
public string FirstName { get; set; }
public string LastName { get; set; }
[Ignore]
public string FullName { get { return FirstName + " " + LastName; } }
...
But, can't seem to dig anything up.
Environment: Xamarin Studio, C#, Android Project running on Mac
回答1:
This is dependant on which serializer you are using:
- For the JsonSerializer, use
[ScriptIgnore]
. - For the DotNetXmlSerializer, use
[System.Xml.Serialization.XmlIgnore]
.
I can't answer with certainty what attribute should be used when you use XmlSerializer but I would suspect it should be either [NonSerialized]
, [ScriptIgnore]
or [XmlIgnore]
.
Documentation:
- ScriptIgnore.
- NonSerialized.
- XmlIgnore.
来源:https://stackoverflow.com/questions/19802479/how-do-i-ignore-properties-when-using-restsharp-serialization