|
Back
Splitting a String into an Array Using C#
This method finds all the substrings in a string that are seperated by one or more characters, returning a string array. This method also has 1 overload where you can specifiy the maximum number of elements in an array to return from the string.
// string seperated by colons ';' string info = "bill;winder;abc;yes;no";
string[] arInfo = new string[0]; // define which character is seperating fields char[] splitter = {';'}; arInfo = info.Split(splitter);
for(int x = 0; x < arInfo.Length; x++) { Response.Write(arInfo[x] + " "); }
Back
|