Not getting items from the list
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
Post a Comment