Marc Gravell wrote:
Well, you could perhaps do it manually? I wouldn't do the entire
serialization yourself, but how about:
[XmlIgnore]
public double Price {...}
[XmlElement("Price")]
public string PriceString {
get {return (your expicit Price.ToString() or whatever);}
set {Price = double.Parse(value);}
}
If you do this, you may wish to explicitely use an invariant culture
in the ToString() / Format().
Also - if you are using data-contracts, note that you can happily make
PriceString private; if the intellisense annoys you can can use
[EditorBrowsable({blah}.Never)] to remove it from view.
Marc
it's perfect...
i use :
private double _paye = 0;
//[XmlElement(ElementName = "paye")]
[XmlIgnore]
public double Paye
{
get { return _paye; }
set { _paye = value; }
}
[XmlElement("paye")]
public string PayeString
{
get { return Paye.ToString("#0.00"); }
set { double.TryParse(value, out _paye); }
}
and i can continue to use my code ! (public object this[string index])
a minimum code change ! perfect !
great thanks for this tips !