473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to serialize a Hashtable

I need to serialize a hash table in a file (xml or other), but I'm new with
all this and I don't know how to serialize. Can you put me a piece of code
to do this?

Regards,

Diego F.
Nov 16 '05 #1
2 4327
Diego F. wrote:
I need to serialize a hash table in a file (xml or other), but I'm
new with all this and I don't know how to serialize. Can you put me a
piece of code to do this?

Regards,

Diego F.


Hi Diego,

A real easy way to do this is using a Soap Formatter (in
System.Runtime.Serialization.Formatters.Soap)

Create a stream (filestream or whatever) and use the serialize method
of the SoapFormatter.

i.e.

HashTable ht = new HashTable();
<snip - Code that populates the HashTable>

SoapFormatter sf = new SoapFormatter();
FileStream fs = new FileStream(TheFileName,FileMode.Create);
sf.Serialize(fs,ht);

(There is a Deserialize method as well to get it back.)

Rgds Tim.
Nov 16 '05 #2
A Hashtable is serializable, that means, you can use a formatter to
serialize it...

Lookup:

Binary.BinaryFormatter class. It has a serialize method that will help you.

-vJ

"Diego F." <di*****@NOterra.es> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
I need to serialize a hash table in a file (xml or other), but I'm new with all this and I don't know how to serialize. Can you put me a piece of code
to do this?

Regards,

Diego F.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brij | last post by:
Hi Guys, kinda hopin someone has an answer to this. I have some user information that i need to dump into a cookie, but its not a straightforward dump. I have a collection of data in a...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
0
by: Arjen | last post by:
Hello, I have made a little test application and needs some help. I have two classes with hash tables which I want to serialize inside one xml file. My question is if someone can make the...
0
by: Arjen | last post by:
Hello, I have made a little test application and needs some help. I have two classes with hash tables which I want to serialize inside one xml file. My question is if someone can make the...
2
by: Diego F. | last post by:
I need to serialize a hash table in a file (xml or other), but I'm new with all this and I don't know how to serialize. Can you put me a piece of code to do this? Regards, Diego F.
2
by: MichiSu11 | last post by:
I want to serialize the properties of controls. I write Property Name and Value to an Hashtable. This hashtable is serialized. So I want to find out which properties of the control are serializable....
1
by: Bill L | last post by:
Hi guys, Because of restarting application after new DLLs installed into \Bin folder , we move the session to StateServer, everything'a alright except when I try to write any simple hash table...
1
by: Raed Sawalha | last post by:
we have already built Web Application,we did changes on in class in application so , we need to pass a Hashtable object to a webserivce, we're using XML Serialization , my problem in how to...
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
5
by: Dick | last post by:
Hello, I'm trying to serialize a class with a Hashtable within: ' Class code: Imports System.Collections Class clsOptions Public countID As Integer Public persons As New Hashtable End Class
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.