User enters a series of values into textboxes:
Textbox 1: 10,9,8,7
Textbox 2: 1,2,3,4
Id then like to sort these two string and populate a List<string>. Once sorted (already figured out how to do that part), id like to create a jagged array of the inputs like so:
string[][] Arr = new string[2][];
Arr[0] = new string[] { "10", "9", "8", "7" };
Arr[1] = .....
but instead of manually typing in the values, id like to use the List<string> mentioned above.
Is this possible (thus far, my attempts have failed rather miserably)? If not, could someone suggest a possible alternative approach?
Thanks for your time!
EDIT: Based on the answers, I got it working. Sorry again for not making it clear what I meant by sort.
List<string> tempString = new List<string>();
tempString.Add("10,9,8,7");
tempString.Add("1,2,3");
string[][] Arr = new string[2][];
for (int x = 0; x < 2; x++)
{
string[] values = tempString[x].Split(',').ToArray();
Arr[x] = values;
}
Create lists from the strings:
Sort the lists:
Now you can easily create arrays from the lists:
If you want to do it in the other order, i.e. first sort then split, it would be: