Guadar numbers of a Texbox in a Vector (array) [duplicated]

-1

I have the following question: How could I save what is in a texbox with numbers separated from each other by commas, which are entered by the user in an array (vector)? The maximum number of numbers that can be entered is 3, and separated by commas, since I need to make a cross product of vectors (Product point). Thank you in advance for the help.

    
asked by Axwell Duarte 28.12.2018 в 17:13
source

1 answer

2

You could use the Split() to separate by the comma

string[] lista = TextBox1.Text.Split(',');

so you would get the array with each value entered

If you need it to be a numerical array change a bit

int[] lista = TextBox1.Text.Split(',').Select(Int32.Parse).ToArray();

but there are several ways to achieve the same thing

Split string, convert ToList () in one line

    
answered by 28.12.2018 в 17:28