Best way to serialize an object to a String

Discussion in 'ASP .Net' started by Patrick Sona, Jul 21, 2008.

  1. Patrick Sona

    Patrick Sona Guest

    Hi all!

    has anyone an idea how to serialize an object to a String without using
    XMLSerializer? The problem is, that i have to serialize a Hashtable to a
    String and the XMLSerializer doesn't accept any object that inherits
    from ICollection. So I have to use the Binary or SoapFormater. But both
    accept only a Stream and .net has no StringStream.

    Thanx!

    Greetings
    Pat
     
    Patrick Sona, Jul 21, 2008
    #1
    1. Advertising

  2. Patrick Sona

    Patrick Sona Guest

    Patrick Sona schrieb:
    > Hi all!
    >
    > has anyone an idea how to serialize an object to a String without using
    > XMLSerializer? The problem is, that i have to serialize a Hashtable to a
    > String and the XMLSerializer doesn't accept any object that inherits
    > from ICollection. So I have to use the Binary or SoapFormater. But both
    > accept only a Stream and .net has no StringStream.
    >
    > Thanx!
    >
    > Greetings
    > Pat


    I have found the solution by my self. The best way to serialize to a
    String is using the MemoryStream, from which you can get a Bytearray.
    This could be converted to a String!

    Greetings
    Pat
     
    Patrick Sona, Jul 21, 2008
    #2
    1. Advertising

  3. Patrick Sona

    sloan Guest

    Take a peak here
    http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!114.entry
    about
    XmlSerialization with IDictionary and CollectionBase Objects
    including a Hashtable.



    "Patrick Sona" <> wrote in message
    news:...
    > Hi all!
    >
    > has anyone an idea how to serialize an object to a String without using
    > XMLSerializer? The problem is, that i have to serialize a Hashtable to a
    > String and the XMLSerializer doesn't accept any object that inherits from
    > ICollection. So I have to use the Binary or SoapFormater. But both accept
    > only a Stream and .net has no StringStream.
    >
    > Thanx!
    >
    > Greetings
    > Pat
     
    sloan, Jul 21, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gordz
    Replies:
    3
    Views:
    3,993
    John Oakes
    Jun 7, 2004
  2. Voronkov Konstantin
    Replies:
    1
    Views:
    415
    Victor Bazarov
    Sep 9, 2004
  3. Voronkov Konstantin
    Replies:
    2
    Views:
    4,535
    Stephan Br?nnimann
    Sep 10, 2004
  4. Colin Song
    Replies:
    11
    Views:
    28,455
    mitumix
    Aug 6, 2010
  5. john harkin
    Replies:
    1
    Views:
    876
    john harkin
    Sep 23, 2004
Loading...

Share This Page