// 显示: 先读取磁盘文件, 在反序列化得到学生列表, 最后逐个显示学生
        private void bntShow_Click(object sender, EventArgs e)
        {
            string          file     = @"d:\C#程序设计\student.dat";
            Stream          stream   = new FileStream(file, FileMode.Open, FileAccess.Read);
            BinaryFormatter bf       = new BinaryFormatter();               // 创建序列化对象
            StudentList     students = (StudentList)bf.Deserialize(stream); // 把流反序列化
            int             k        = 0;

            while (students[k] != null) // 逐个显示学生数据
            {
                string s_no   = students[k].student_no;
                string name   = students[k].name;
                string depart = students[k].department;
                string result = String.Format("{0}\t{1}\t{2}", s_no, name, depart);
                lbResult.Items.Add(result);
                k++;
            }
            stream.Close();
        }
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            txtFileName.Text = openFileDialog1.FileName;                    // 返回选中的文件名
            Stream          stream   = openFileDialog1.OpenFile();          // 打开选中的文件
            BinaryFormatter bf       = new BinaryFormatter();               // 创建序列化对象
            StudentList     students = (StudentList)bf.Deserialize(stream); // 把流反向序列化
            int             k        = 0;

            while (students[k] != null) // 逐个显示学生列表中的数据
            {
                string s_no   = students[k].student_no;
                string name   = students[k].name;
                string depart = students[k].department;
                string result = String.Format("{0}\t{1}\t{2}", s_no, name, depart);
                lbResult.Items.Add(result);
                k++;
            }
            stream.Close();
        }