Groups | Blog | Home
all groups > dotnet xml > august 2003 >

dotnet xml : property serialisation


erez shalom
8/17/2003 5:39:35 PM
Hi ,
i have :

public classA
{

private int id;

public int id{get...,set....)
}

i want to serialize the field id,but i don't want to make him public(it
works like that way).
in the msdn it noted that public properties can be serialize too,but when i
put the[xmlattribute] with the property-it fails.
do i have to make my field public, or i can work just with the property?
thanks
erez

Oleg Tkachenko
8/17/2003 6:55:50 PM
[quoted text, click to view]

Actually that's synatax error. You cannot have field and property with the
same name.

[quoted text, click to view]
Only public members are subject to serialization process.

[quoted text, click to view]
Property would be ok. It must be read-write though (both getter and setter
must be defined). And try [XmlAttribute] attribute instead (watch the case).
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
AddThis Social Bookmark Button