Getting numbers entered into a text field in an array

how can i get the numbers entered into a text field in an array.

eg:

enter 33.21.5.8 in the text box

and I want to create an array with these numbers, how can I do this? thanks in advance

+3
source share
2 answers
Int32[] numbers = textbox1.Text.Split(',').Select(s => Int32.Parse(s)).ToArray();

to get the first element, use the following code:

Int32[] numbers = textbox1.Text.Split(',').Select(s => Int32.Parse(s)).ToArray();
Int32 firstNumber = numbers.First();
+8
source
private static void ConvertStringToArray(string p)
{
string[] CardsToBeSortedArray = p.Split(',');
int[] IntCard = Array.ConvertAll<string, int>(CardsToBeSortedArray, delegate(string
card)
{
int result;
int32.TryParse(card, out result);
return result;
});
}
+1
source

Source: https://habr.com/ru/post/1779726/


All Articles