"Julia" <codewizard@012 .net.il> wrote:
[color=blue]
> I want to serialize an integer member as an empty
> string when the member value is set to zero[/color]
You can do this by marking your integer 'XmlIgnore' and exposing a
string property instead. The string property's get and set accessors
will be called when serialising and deserialising.
[XmlIgnore] private int myInt;
public string myIntToSerialis e
{
get
{
return (myInt == 0) ? "" : myInt.ToString( );
}
set
{
myInt = (value == "") ? 0 : Int32.Parse(val ue);
}
}
You will have to change the default serialization behaviour and
implement the ISerializable interface to change how the values are stored.
--
Patrik Löwendahl [C# MVP]
cshrp.net - 'Elegant code by witty programmers'
cornerstone.se 'IT Training for professionals'
Julia wrote:[color=blue]
> Hi,
>
> I want to serialize an integer member as an empty string
> when the member value is set to zero
>
> Thanks.
>
>[/color]
Comment