Home All Groups Group Topic Archive Search About

serialize to string

Author
7 Mar 2006 11:45 AM
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;
}



Author
7 Mar 2006 2:40 PM
johan.appelgren@gmail.com
How are you serializing your object? And can't you serialize to a
anything but a file?
Author
7 Mar 2006 2:56 PM
johan.appelgren@gmail.com
How do you serialize it? Why can you only serialize to a file?
Author
8 Mar 2006 5:55 AM
Chris Taylor
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
>
>
>
>

AddThis Social Bookmark Button