I'm building a small application and I need to store my data to file. I read some about saving objects. I have done this before in Java, but that was some years ago. Then I saved the hole array of objets and I wonder if I can do the same in C# and how that is done?
I'm using a List that is called Animals and I have also serialized that class, because that was a demand in this task. If I have serialized the Animal class, then I guess I don't need to serialize sub classes to Animal?
Some help is preciated, thanks!
EDIT:
Hi agian! I have made some test code to save a list and I just wonder if I'm doing right? I have not added any Try/Catch code yet. When I should open the file and read the list, will the list be loaded as a whole? Feedback is preciated!
filestream = new FileStream(filePath, FileMode.Create);
BinaryFormatter b = new BinaryFormatter();
b.Serialize(filestream, animals);
filestream.Close();