private void MistakesButton_Click(object sender, EventArgs e) { Random randomNumber = new Random(); int minValue = 1; int maxValue = 100; int mistakes = Convert.ToInt32(NumMistakes.Value); if (mistakes == 0) { MessageBox.Show("Nie można wstawić 0 błędów " + "\n"); } if (mistakes > gridMultiset.Count) { MessageBox.Show("Nie można wstawić więcej błędów niż liczba elementów: " + gridMultiset.Count.ToString() + "\n"); } else { for (int i = 0; i < mistakes; i++) { int index = randomNumber.Next(0, gridMultiset.Count); int value = randomNumber.Next(minValue: minValue, maxValue: maxValue); gridMultiset[index] = new multiSet() { elementOfmultiSet = value }; } MultisetGrid.Refresh(); } }
public static multiSet FromCsv(string csvLine) { char[] delimiterChars = { ' ', ',', '.', ':', '\t', ';' }; string[] str = csvLine.Split(delimiterChars); int value; bool success = int.TryParse(str[0], out value); multiSet multiElement = new multiSet() { elementOfmultiSet = Math.Abs(value) }; return(multiElement); }