I am trying to enter multiple values into a textbox and when I press a button they will be stored in an array. Like this: 1.1, 2.2, 3.3, 4.4, 5.5 Then press the button and they are stored in index 0, 1, 2, 3, 4
I understand that the values are a string and need to be converted, I think I am close to the answer but I am not sure, here is what I have been trying:
private void textBox1_TextChanged(object sender, EventArgs e)
{
//five values entered from textbox
string values = textBox1.Text;
string[] EmailArr = values.Split(',');
double[] yArray = new double[5] = Array.ConvertAll(values.Split(','), Double.Parse);
}
I know this is wrong, but is it along the right lines? Any help is appreciated! Thank you!
the linq way :
By the way, don’t use that with a TextChanged event, rather with a Validated, or a Clicked on your button.
Edit
Follow this steps :
Double click on “YourForm”.cs (to have the “design”).
Select your TextBox.
Right click, choose “Properties”.
See the “Event list”.
Remove anything on line “TextChanged”
DoubleClick on line Validated (this will add text on this line)
This should open the “code” part.
Past my answer’s code into the new method “private void textBox1_Validated(…)”
Remove all the code present in your question.