Answer the question
In order to leave comments, you need to log in
How to set up an XML serializer?
Good afternoon.
Sending an XML request to a Web server. He wants boolean true to be encoded as "Y", false as "N". As a result, the serializable class class looks like
public string MyBool
{
get{ return _myBool;}
set
{
if(value == "Y" || value == "N"){ _myBool = value;}
else {throw new Exception();}
}
}
public bool MyBool
that would (de)serialize to a string according to the above rule?
Answer the question
In order to leave comments, you need to log in
stackoverflow.com/questions/84449/xml-serialize-bo...
[XmlIgnore]
public bool MyValue { get; set; }
/// <summary>Get a value purely for serialization purposes</summary>
[XmlElement("MyValue")]
public string MyValueSerialize
{
get { return this.MyValue ? "1" : "0" }
set { this.MyValue = XmlConvert.ToBoolean(value); }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question