Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Serialize an Object with a Hashtable of Objects

Serialize an Object with a Hashtable of Objects

Scheduled Pinned Locked Moved C#
data-structurestutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gilad Kapelushnik
    wrote on last edited by
    #1

    Hello I need to Serialize an object containing a hashtable where each value in the hashtable is an object. [Serializable] class A{ public ushort[] UshortArray; // lets assume this points to an array } [Serializable] class B{ public Hashtable HashOfA; } void Main(){ A A1 = new A(); A A2 = new A(); B B1 = new B(); B1.Init() // Set hashtable B1.Add(1,A1); // add item B1.Add(2,A2); // add item byte[] Binary; ///////////////////////////////// // Here I want to serialize B1 to binary format ////////////////////////////////// B B2 = new B(); /////////////////////////////////////// // And ofcourse back to object B2 /////////////////////////////////////// } I know how to do this where insted of I have . Is there a solution for objects ? I'm using a MemoryStream and BinaryFormatter. Gilad.

    S 1 Reply Last reply
    0
    • G Gilad Kapelushnik

      Hello I need to Serialize an object containing a hashtable where each value in the hashtable is an object. [Serializable] class A{ public ushort[] UshortArray; // lets assume this points to an array } [Serializable] class B{ public Hashtable HashOfA; } void Main(){ A A1 = new A(); A A2 = new A(); B B1 = new B(); B1.Init() // Set hashtable B1.Add(1,A1); // add item B1.Add(2,A2); // add item byte[] Binary; ///////////////////////////////// // Here I want to serialize B1 to binary format ////////////////////////////////// B B2 = new B(); /////////////////////////////////////// // And ofcourse back to object B2 /////////////////////////////////////// } I know how to do this where insted of I have . Is there a solution for objects ? I'm using a MemoryStream and BinaryFormatter. Gilad.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Shouldn't make any difference at all. What problem are you facing? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups