473,491 Members | 2,221 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4333
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
556
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
24657
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
216
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
1058
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
819
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
2300
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
3702
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
3918
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
3519
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
2674
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
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.