I am trying to save data object to a file. I followed the example http://tech.pro/tutorial/618/csharp-tutorial-serialize-objects-to-a-file
And it is working well on window and android device. When I try to run it on iPhone or iPad it is giving error.
I think the error due to BinaryFormatter
Can anyone give some help on proper way to do this?
I think the problem comes from the List in the object. If I don’t have any list all get saved properly. Any idea how to solve this?
The example in the link has following code
[Serializable()]
public class NameSeriClas : ISerializable
{
List<NameClas> nameClasList;
public List<NameClas> NameClasList
{
set
{
this.nameClasList = value;
}
get
{
return this.nameClasList;
}
}
public NameSeriClas()
{
}
public NameSeriClas(SerializationInfo info, StreamingContext cxtx)
{
this.nameClasList = (List<NameClas>)info.GetValue("NameClasList", typeof(List<NameClas>));
}
public void GetObjectData(SerializationInfo info, StreamingContext cxtx)
{
info.AddValue("NameClasList", this.nameClasList);
}
}