Extracting multiple array values from a ListBox item

I’ve put three arrays into one line in a list box as such:

Listbox.Items.Add(array1[i] + "t" + array2[i] + "t" + array3[i]);

I want to be able to select one line, which would contain all 3 arrays, and split the three values, one from each array, into 3 separate strings. Right now I’m able to do:

string currentSelected = ListBox.GetItemText(ListBox.SelectedItem);

But this gives me all 3 array values in one string.

Answer

You can use the Split method to do what you want:

string currentSelected = ListBox.GetItemText(ListBox.SelectedItem);
string[] values = currentSelected.Split('t');