Hi
i have an application in which i save my data, save it to the database and then fetch the data whenever i need it, something like save and restore
i have list<> of objects (class) and serialize them to binary data then deserialize it for restoring,i can see that the data saved and restored as well, but when i run my program there is an error that i really don`t understand where it came from , if i run my application without save and restore , it will run without error but after restoring the same data the program will interrupt with an error, the details of my class and the error are explained below.
class i think related to the error :
[Serializable]
class prof:faculty
{
public prof(string n, int ID, string f, string d, int did) : base(f,d,did)
{ nprof++; id = ID; name = n; }
public prof(string n, int ID,faculty f, department d)
: base(f,d)
{
nprof++; id = ID; name = n;
}
public prof(prof p, faculty f, department d)
: base(f,d)
{id=p.FId; name = p.FName; }
public int PId { get { return id; } set { id = value; } }
public string PName { get { return name; } set { name = value; } }
public static int Nprof { get { return nprof; } }
public void addcourse(course c) { teaching.Add(c); }
public List<course> Teaching { get { return teaching; } }
public void addtime(int d, int[] s) { teachingprog.Add(d,s); }
public Dictionary<int, int[]> Teachingprog { get { return teachingprog; } }
private string name;
private int id;
public Dictionary<int, int[]> teachingprog = new Dictionary<int, int[]>();
private List<course> teaching = new List<course>();
static int nprof = 0;
}
error:
foreach (course cc in p.Teaching)
for (int j = 0; j < Nroom; j++)
{
int ii = Courses.IndexOf(cc);
this is the error part, int ii valued with -1(makes its following computation wrong) which if i am not wrong means cc could not be found in courses list<>
but why?
i serialize the prof list<> and the courses<> list
no error before save and restore, but after restore there is a error