Text property of the TextBox element. Gets or sets the text content of the text field ( string ).
To create an array of a given length, you must use the following construction:
type[] array = new type[N];
Where
- type - the type of variables contained in the array. The array elements can be of any type, including the type of the array;
- N is the number of elements in the array. Must be represented by a positive integer, including 0. The table of integer types can be viewed on the MSDN website
In this particular case, you pass the type string .
string [] myArr = new string [TextBox.Text];
To solve the problem, you must cast the contents of TextBox.Text to an integer type. I will give an example of conversion. This example takes into account that the correct data is entered in TextBox.Text .
n = int.Parse(TextBox.Text);