Hi
I want to save a list as follows, but it will not load after save.
public List<c> ct = new List<c>();
[System.Serializable]
public class c
{
public string a;
public int b;
}
--------
public void ex()
{
BinaryFormatter bi = new BinaryFormatter();
FileStream file = File.Create("ct.zip");
bi.Serialize(file, ct);
file.Close();
}
public void in()
{
BinaryFormatter bi = new BinaryFormatter();
FileStream file = File.Open("ct.zip", FileMode.Open);
ct = (List<c>)bi.Deserialize(file);
file.Close();
print ( ct[0].a );
}
What is happening versus what you expect to happen? Are there compiler errors? Are there runtime exceptions? What are those? We need more information.
This is a free forum where people donate their time to assist. We generally won’t put in a significant amount of work assisting if you can’t put in the effort explaining details about the problem.
The code I wrote does not load anything and does not give any errors
Note : I want to save and retrieve the list of custom class
important : I want to use the ability to remove and insert an element in the list , not use from struct or class to form of sequential add and delete , i want save list of class and load it in one list again and use it to form of list