Not getting items from the list


i have 2 lists 1 juniorstudents , 1 seniorstudents. in juniorstudents have method promoting juniorstudent seniorstudent. first deleting juniorstudent , putting seniorstudent list. when try view student when calling method viewstudents not getting student. ideas why so. here code:
ublic class seniorstudentsclass      {          public list<student> studlist = new list<student>();    public void viewstudents()          {              (int = 0; < studlist.count; i++)              {                                 console.write(studlist[i].id + "\t");                  console.write(studlist[i].year + "\t");                  console.write(studlist[i].name + "\t");                  console.write(studlist[i].surname + "\t");                  console.write(studlist[i].dob + "\t");                  console.write(studlist[i].addr);                  console.writeline();              }      public class juniorstudentsclass      {         public list<student> mystudent = new list<student>();           seniorstudentsclass sc = new seniorstudentsclass();            public void promotestudents(int index)          {              searchitem(index);              console.writeline("current record:");              console.writeline("id is:" + mystudent[index].id);              console.writeline("year is:" + mystudent[index].year);              console.writeline("name is:" + mystudent[index].name);              console.writeline("surname is:" + mystudent[index].surname);              console.writeline("dob is:" + mystudent[index].dob);              console.writeline("address is:" + mystudent[index].addr);              console.writeline("year is:"+mystudent[index].year);              if (((mystudent[index].year== 7)) || ((mystudent[index].year == 8)))              {                  var student = mystudent[index];                  mystudent.removeat(index);                  sc.studlist.add(student);                  console.writeline("student promoted senior student");            }

as thought.

you promote student , add him cs.sc.studlist.

then call ss.viewstudents().

so have 2 seniorstudentclasses. 1 static in main class , 1 in juniorstudentclass.

either give juniorstudentclass access static seniorstudentclass or pass reference in method, e.g.: promotestudents(int index, ref seniorstudenclass ss);



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user