Beispiel #1
0
        public frmMain()
        {
            InitializeComponent();

            stu = new CollegeStudent();
            //将学生默认信息显示在窗体上
            this.ClearInputControls();
        }
Beispiel #2
0
 //更新对象信息
 private void UpdateStudentObj(CollegeStudent stu)
 {
     if (stu == null)
     {
         return;
     }
     stu.IsMale = rdoMale.Checked;
     stu.Name   = txtName.Text;
     stu.ScoreForEntranceExamination = Convert.ToInt32(txtScore.Text);
 }
Beispiel #3
0
 //将学生信息显示在窗体上
 private void ShowStudentInfo(CollegeStudent obj)
 {
     if (obj == null)
     {
         return;
     }
     this.txtName.Text      = obj.Name;
     this.txtScore.Text     = Convert.ToString(obj.ScoreForEntranceExamination);
     this.rdoMale.Checked   = obj.IsMale;
     this.rdoFemale.Checked = !obj.IsMale;
 }
Beispiel #4
0
 //将CollegeStudent对象序列化到文件中
 private void SerializeObj(String FileName, CollegeStudent stu)
 {
     //创建FileStream对象
     using (FileStream writer = new FileStream(FileName, FileMode.Create))
     {
         //创建格式化器对象
         IFormatter formatter = new BinaryFormatter();
         //格式化器对象使用FileStream对象序列化对象
         formatter.Serialize(writer, stu);
         MessageBox.Show("对象成功保存到文件:" + FileName);
     }
 }