/// <summary> /// Takes a list of textBoxes, try to convert each element into a double, /// if an element is not a double, skip it, and send the dictionary into /// the stringDecoder class, and return the result. /// </summary> public string EncodeDataFromTextBoxes(List <TextBox> textBoxes) { var dictionary = new Dictionary <int, double>(); var values = textBoxes.Select(textBox => textBox.Text).ToList(); for (int i = 0; i < values.Count; i++) { try { double temperature = Convert.ToDouble(values[i]); dictionary.Add(i, temperature); } catch { /* If text is not a double, ignore. */ } } return(StringDecoder.dictionaryToString(dictionary)); } // End of TakeInfoFromTextBoxes