現在、'|' を取得しようとしている最中です。区切りテキスト ファイルを作成し、そこに含まれるデータからオブジェクトを作成します。例:
Name|Address|City|State|Zip|Birthday|ID|Etc.
Name2|Address2|City2|State2|Zip2|Birthday2|ID2|Etc.
次に、新しく作成されたオブジェクトが上記のオブジェクトのリストに追加され、プログラムは .Peek() を使用して while ループを介してファイルの次の行に移動します (ファイル)。
ただし、2 番目のオブジェクト (より具体的には、2 番目のオブジェクトの 2 番目のフィールド) を作成すると、Index Out Of Range Exception がスローされます。これを読んでくれた人、ありがとう!
    StreamReader textIn = new StreamReader(new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read));
        List<Student> students = new List<Student>();
        while (textIn.Peek() != -1)
        {
            string row = textIn.ReadLine();
            MessageBox.Show(row);
            string [] fields = row.Split('|');
            Student temp = new Student();
            try
            {
                temp.name = fields[0];
                temp.address = fields[1];
                temp.city = fields[2];
                temp.state = fields[3];
                temp.zipCode = Convert.ToInt32(fields[4]);
                temp.birthdate = fields[5];
                temp.studentID = Convert.ToInt32(fields[6]);
                temp.sGPA = Convert.ToDouble(fields[7]);
            }
            catch
            {
                MessageBox.Show("IndexOutOfRangeException caught");
            }
            students.Add(temp);
        }
        textIn.Close();