public void Shuffle(List <AnswerABC> list) { Random rng = new Random(); AnswerABC a = new AnswerABC(); int n = list.Count; while (n > 1) { n--; int k = rng.Next(n + 1); a = list[k]; list[k] = list[n]; list[n] = a; } }
protected List <AnswerABC> GetAnswersFromTable(Table tbl) { List <AnswerABC> listAnswer = new List <AnswerABC>(); AnswerABC answer = new AnswerABC(); Label lblAnswer = new Label(); CheckBox chbxIsRight = new CheckBox(); foreach (TableRow tRow in tbl.Rows) { foreach (TableCell tCell in tRow.Cells) { foreach (Control ctrl in tCell.Controls) { if (ctrl.GetType().ToString() == lblAnswer.GetType().ToString()) { lblAnswer = (Label)ctrl; if (lblAnswer.ID != null) { if (ctrl.ID.StartsWith("lblAnswer")) { answer.AnswerCurrent = lblAnswer.Text; lblAnswer = new Label(); } } } else if (ctrl.GetType().ToString() == chbxIsRight.GetType().ToString()) { chbxIsRight = (CheckBox)ctrl; answer.IsRight = chbxIsRight.Checked; chbxIsRight = new CheckBox(); } } } listAnswer.Add(answer); answer = new AnswerABC(); } return(listAnswer); }