tags:

views:

178

answers:

3

I have a simple program where I would like to save an arraylist to a file, so that when the program is restarted, it loads from the file to the arraylist in memory.

Is this possible in C#? Or do I need to itterate over the arraylist countaining my custom classes and in someway print them out?

Any tips on a correct way to do this?

+3  A: 

You will want to look into Serialization. Here's a link to get you going.

SB
Looking into it. Seems to be what I need to implement at first look. Thanks
Milan
+1  A: 

Yes,instead of ArrayList ,use List<T> and store the data in XML file .When the program starts up read that XML file.

Srinivas Reddy Thatiparthy
Sounds good, but I can't change that now since I have been using that arraylist everywhere in the program. Would rather find an alternative instead if it goes.
Milan
+1  A: 

Look at the DeSerializeObject and SerializeObject methods in this post

http://weblogs.asp.net/rajbk/archive/2009/10/04/xmlserializer-and-invalid-xml.aspx

Raj Kaimal