Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         private void btketthuc_Click(object sender, EventArgs e)
         {
             if (MessageBox.Show("Bạn có chắc chắn kết thúc không ?" , "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
             {
                 this.Hide();
                 try
                 {
                     timer1.Stop();
                     btketthuc.Enabled = false;

                     GhiLaiDapAnTS();
                     SoCauDung = 0;
                     for (int i = 0; i < SoCauHoi; i++)
                     {
                         if (BangDeThi.Rows[i][6].ToString().ToUpper() == BangDeThi.Rows[i][7].ToString().ToUpper())
                             SoCauDung++;

                     }

                     diem = SoCauDung * 2;
                     MessageBox.Show("Đúng " + SoCauDung.ToString() + " câu " + " Bạn được " + diem.ToString() + " điểm ");
                     this.Close();
                     string ten = lbhoten.Text;
                     string mats = lbmathisinh.Text;
                     string diem1 = diem.ToString();
                     string socaudung = SoCauDung.ToString();
                     frmKetQua ketqua = new frmKetQua(ten,mats,diem1,socaudung);
                     ketqua.ShowDialog();
                     //them form ket qua tai day

                 }
                 catch (Exception ex)
                 { MessageBox.Show(ex.Message); }
             }
             else
             { return; }
         }