Using a List in another class
<p>I have a list in a class and now I want to update its properties in another class. I am doing this by first the user is asked to enter index of list for the record s/he wants to update but when I do so I am getting an outofrange exception error. Can someone tell me what am I doing wrong. Here is what I did to get the list from the other class:</p>

<pre><code>public class JuniorStudentsClass
    {
        public List&lt;Student&gt; mystudent = new List&lt;Student&gt;();

        public List&lt;Student&gt; GetList()
        {
            return mystudent;
        }

 public class SeniorStudentsClass : JuniorStudentsClass
    {
        Student st = new Student();
        static JuniorStudentsClass js = new JuniorStudentsClass();
        List&lt;Student&gt; seniorList = js.GetList();

        public void Updatestudent(int index)
        {
            SearchItem(index);
            GetList();
            Console.WriteLine("current record:");
            Console.WriteLine("id is:" + seniorList[index].Id);
            Console.WriteLine("year is:" + seniorList[index].Year);
            Console.WriteLine("name is:" + seniorList[index].Name);
            Console.WriteLine("surname is:" + seniorList[index].Surname);
            Console.WriteLine("dob is:" + seniorList[index].DOB);
            Console.WriteLine("address is:" + seniorList[index].Addr);
            foreach (Student st in mystudent)
            {
                Console.WriteLine("enter new students year:");
                st.Year = Int16.Parse(Console.ReadLine());
                seniorList[index].Id = st.Id;
                seniorList[index].Name = st.Name;
                seniorList[index].Surname = st.Surname;
                seniorList[index].DOB = st.DOB;
                seniorList[index].Addr = st.Addr;
                seniorList.Add(new Student(st.Id, st.Year, st.Name, st.Surname, st.DOB, st.Addr));

            }
  public int SearchItem(int search)
        {
            int found = -1;
            if (mystudent != null)
            {
                foreach (Student st in mystudent)
                {
                    found++;
                    if (Student.Equals(search, st))
                    {
                        break;
                    }

                }
            }
            return found;
        }

        } 
</code></pre>
