I’m trying to convert a textbox entry into a Dictionary of double, double. i.e.
Input text is:
1,63
2,31
3,78
4,83
I’m then splitting the row by a comma (,).
I’ve got the code below – but the IEnumerable isnt working. Any help would be much appreciated!!
string input = txtInput.Text;
List<string> list = new List<string>(
input.Split(new string[] { "\r\n" },
StringSplitOptions.RemoveEmptyEntries));
IEnumerable<Dictionary<double, double>> dict = list.Select(row => row.Split(','))
.Select(pair => new Dictionary<string, string>(double.Parse(pair[0]), double.Parse(pair[1])));
Sounds like you probably want:
However:
doublevalues for equalty (required by a dictionary) is generally a bad idea. Can you useintordecimalinstead?