How do i split a String into multiple values?
问题 How do you split a string? Lets say i have a string "dog, cat, mouse,bird" My actual goal is to insert each of those animals into a listBox, so they would become items in a list box. but i think i get the idea on how to insert those items if i know how to split the string. or does anyone know a better way to do this? im using asp c# 回答1: string[] tokens = text.Split(','); for (int i = 0; i < tokens.Length; i++) { yourListBox.Add(new ListItem(token[i], token[i])); } 回答2: Have you tried String