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
  1. Home
  2. General Programming
  3. C#
  4. XML Serialize Hashtable..

XML Serialize Hashtable..

Scheduled Pinned Locked Moved C#
xmlhelptutorial
4 Posts 4 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.
  • N Offline
    N Offline
    nasambur
    wrote on last edited by
    #1

    hi.. i want to serialize a Hashtable to a XML file.. how to do this.. currently i m using List<> to store objects, and serializing the List<> and its working fine.. but how to serialize a Hashtable.. plz help me.. regards, nas

    L B P 3 Replies Last reply
    0
    • N nasambur

      hi.. i want to serialize a Hashtable to a XML file.. how to do this.. currently i m using List<> to store objects, and serializing the List<> and its working fine.. but how to serialize a Hashtable.. plz help me.. regards, nas

      L Offline
      L Offline
      Luka Grabarevic
      wrote on last edited by
      #2

      Hi as far as I know it's not possible to serialize a Hashtable. I had the same problems some time ago. You could use the Dictionary<> which is in .NET 2.0, I think. It has the same functionality as the Hashtable. greetings pdluke

      1 Reply Last reply
      0
      • N nasambur

        hi.. i want to serialize a Hashtable to a XML file.. how to do this.. currently i m using List<> to store objects, and serializing the List<> and its working fine.. but how to serialize a Hashtable.. plz help me.. regards, nas

        B Offline
        B Offline
        Blumen
        wrote on last edited by
        #3

        try this: Hashtable.GetObjectData Method

        1 Reply Last reply
        0
        • N nasambur

          hi.. i want to serialize a Hashtable to a XML file.. how to do this.. currently i m using List<> to store objects, and serializing the List<> and its working fine.. but how to serialize a Hashtable.. plz help me.. regards, nas

          P Offline
          P Offline
          Piyush Wattamwar
          wrote on last edited by
          #4

          i have tried it but it is not possible using hashtable. till i send you code which i have tried. using System; using System.Collections.Generic; using System.Text; using System.Runtime.Serialization; using System.Xml.Serialization; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Collections; namespace HAshxml { [Serializable] public class test { public int height; public int length; public test() { Console.WriteLine("Inside test parameter less constructor"); } public test(int x,int y) { height = x; length = y; Console.WriteLine("Inside test constructor"); } public void GetObjectData(SerializationInfo info,StreamingContext context) { Console.WriteLine("Inside Get object data"); } } public class Program { static void Main(string[] args) { test t = new test(10,20); Hashtable ht = new Hashtable(); ht.Add("h", t); Stream str = File.OpenWrite("D:\\abc.xml"); //BinaryFormatter formatter = new BinaryFormatter(); XmlSerializer ser = new XmlSerializer(typeof(test)); ser.Serialize(str, ht); str.Close(); //formatter.Serialize(str, ht); //str.Close(); //XmlTextWriter xl=new XmlTextWriter ( Console.ReadLine(); } } }

          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