CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012

    Not getting items from the list

    I have 2 lists one for JuniorStudents and one for SeniorStudents. In the JuniorStudents I have a method for promoting a juniorstudent to a seniorStudent. I am first deleting the juniorstudent and then putting it into the seniorstudent list. However when I try to view the student when calling the method viewStudents I am not getting the student. Any ideas why this is so. Here is the code:
    public class SeniorStudentsClass
            public List<Student> studlist = new List<Student>();
    public void ViewStudents()
                for (int i = 0; i < 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");
      public class JuniorStudentsClass
           public List<Student> mystudent = new List<Student>();  
           SeniorStudentsClass sc = new SeniorStudentsClass();
            public void PromoteStudents(int 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];
                    Console.WriteLine("student promoted to senior student");

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: Not getting items from the list

    I note your earlier post as well re same topic. If you care to post the complete code that complies and runs and produces the problem I'll have a look at it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.