serialize to string

  • Thread starter Thread starter gusse.net
  • Start date Start date
G

gusse.net

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;
}
 
How are you serializing your object? And can't you serialize to a
anything but 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
 
Back
Top