|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
serialize to stringhow can i serialize a class to a string ? i can write the data to a xml
file, but i would like to write to content into a string instead without using a file... I could write it to a xml file and from there into a string, but that would not be the prefered method.. class test { public name; public number; } How are you serializing your object? And can't you serialize to a
anything but a file? How do you serialize it? Why can you only serialize to a file?
Hi,
Since you have not been very forth coming with information I will assume you are referring to XmlSerializer. If this is the case, you can pass the Serialize method an instance of a StringWriter as the first argument, once the Serialize method returns you can invoke ToString() on the StringWriter instance to get the Xml string. Hope this helps Show quote "gusse.net" <b*@gusseORNOT.net> wrote in message news:%23xQkdydQGHA.4452@TK2MSFTNGP12.phx.gbl... > how can i serialize a class to a string ? i can write the data to a xml > file, but i would like to write to content into a string instead without > using a file... > > I could write it to a xml file and from there into a string, but that > would not be the prefered method.. > > class test > { > public name; > public number; > } > > > -- > gusse > www.gusse.net > > > > |
|||||||||||||||||||||||