Adding items to a list
<p>I have a list one for students and one for marks. I want to add student marks according to the id entered and then view the records. I'm not implementing it correctly. Can someone tell me how to do it correctly please?
This is the output I am trying to achieve:
1) add student
2)add marks: user will be asked to enter id and according to the id if it exists then marks will be stored according to that id.
3)View Marks: view student id and his marks</p>

<pre><code>class Student
{     
    public Student(string name, string surname, string dob, string address)
    {
        this.Name = name;
        this.Surname = surname;
        this.DOB = dob;
        this.Address = address;
    }

    public List&lt;Marks&gt; studentId = new List&lt;Marks&gt;();
    public List&lt;Marks&gt; Mathematics = new List&lt;Marks&gt;();
    public List&lt;Marks&gt; English = new List&lt;Marks&gt;();
    public List&lt;Marks&gt; Maltese = new List&lt;Marks&gt;();
    public List&lt;Marks&gt; ReligiousStudies = new List&lt;Marks&gt;();
    public List&lt;Marks&gt; SocialStudies = new List&lt;Marks&gt;();

    public string Name { get; set; }
    public string Surname { get; set; }
    public string DOB { get; set; }
    public string Addr { get; set; }
    public string Id { get; set; }

    public Student(string s)
    {
        string[] splitted = s.Split(',');
        name = splitted[0];
        surname = splitted[1];
        dob = splitted[2];
        address = splitted[3];
        id = splitted[4];          
     }

    public void AddMarks(string id, int hyexam, int anexam)
    {
        if (Id.Equals(id))
        {
            studentId.Add(new Marks(id));
            Mathematics.Add(new Marks(hyexam, anexam));
            English.Add(new Marks(hyexam, anexam));
            Maltese.Add(new Marks(hyexam, anexam));
            ReligiousStudies.Add(new Marks(hyexam, anexam));
            SocialStudies.Add(new Marks(hyexam, anexam));
        }
        else
        {
            Console.WriteLine("id not found");
        }
    }

    public void StudMarks()
    {
        foreach (Marks mrk in studentId)
        {
            Console.WriteLine(mrk);
        }
        foreach (Marks mrk in Mathematics)
        {
            Console.WriteLine(mrk);
        }

        foreach (Marks mrk in English)
        {
            Console.WriteLine(mrk);
        }

        foreach (Marks mrk in Maltese)
        {
            Console.WriteLine(mrk);
        }

        foreach (Marks mrk in ReligiousStudies)
        {
            Console.WriteLine(mrk);
        }            
     }           
   }
}

public class ClassYear 
{               
    private const string filestud = "C:\\Users\\Maria\\Desktop\\Students\\stud.txt";    
    public string Year { get; set; }
    public List&lt;Student&gt; mystudent=new List &lt;Student&gt; ();
    public List&lt;Student&gt; MyStud
    {
        get { return mystudent; }
    }

    public void Addstudent(string name,string surname,string dob, string addr)
    {
        mystudent.Add(new Student(name,surname,dob,addr));                   
    }

    private void LoadFromFile()
    {
        try
        {
            string s;
            StreamReader myFile = File.OpenText(filestud);
            while ((s = myFile.ReadLine()) != null)
            {
                Student st = new Student(s);
                mystudent.Add(st);
            }
            myFile.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine("There was a file handling problem");
        }
    }

    private void DumpToFile()
    {
        try
        {
            StreamWriter myFile = File.CreateText(filestud);
            foreach (Student s in mystudent)
            {
                myFile.WriteLine(s.ToString());
            }
            myFile.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine("There was a file handling problem");
        }
    }

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

    private void Delete(int index)
    {
        SearchItem(index);
        mystudent.RemoveAt(index);
        foreach (Student st in mystudent) {
            Console.WriteLine(st);
        }            
    }

    private void EditItem(int index)        
    {
        Student stud = new Student();        
        SearchItem(index);
        mystudent[index] = stud;
        Console.WriteLine("current record is" + index);
        Console.WriteLine("enter new record:");
        stud.Name = Console.ReadLine();
        stud.Surname = Console.ReadLine();
        stud.Addr = Console.ReadLine();
        stud.Id = Console.ReadLine();
        foreach (Student st in mystudent)
        {
            Console.WriteLine(st);
        }
    }
    private void ViewStudents()
    {
        foreach (Student st in mystudent)
        {
            Console.WriteLine(st);
        }
    }                    
 }  
 }

public class Marks
{      
    public int HYEXAM { get; private set; }
    public int ANEXAM { get; private set; }
    public string Id { get; private set; }

    public Marks(int hyexam, int anexam)
    {          
        this.HYEXAM = hyexam;
        this.ANEXAM = anexam;
    }

    public Marks(string id)
    {
        this.Id = id;
    }

    public double OverallExam()
    {
        return (0.4 * HEYXAM) + (0.6 * ANEXAM);
    }
   }
 }  
</code></pre>
