Often used in the split, here to do a systematic summary.
Split function
Role
Returns a zero-based, one-dimensional array of subscripts that contains the specified number of substrings.
Grammar
Split (expression[, delimiter[, count[, compare]])
(2) delimiter optional. A string character used to identify the bounds of a substring. If omitted, an empty characters (" ") is used as the delimiter. If delimiter is a zero-length string, the returned array contains only an element, which is the complete expression string.
(3) Count optional. The number of substrings to return, and –1 indicates that all substrings are returned.
(4) compare optional. A numeric value that represents the comparison method used when distinguishing substrings. For its value, see the Setting Values section.
instance:
(1) One of the most commonly used interception methods, as follows:
String str= "1,2,3,4";
string [] strarray=str1.split (', '); Get an array of Strarray {"1", "2", "3", "4"}
foreach (string s in Strarray)
{
Response.writeline (s+ "<br/>");
}
Results
1
2
3
4
(2) Use multiple characters to intercept, as follows:
String str= "1,2,3,4.5";
String Strarray=strarray.split (New char[2]{', ', '. '});
foreach (string var in strarray) {
Response.writeline (var + "<br/>");
}
Output results
1
2
3
4
5
(3) using System.Text.RegularExpressions (regular expressions in a frame to intercept according to a string) such as:
String str= "Mokeybigtigerbigschool";
String[] strname= System.Text.RegularExpressions.Regex.Split (str, "big", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach (string var in strName)
{
Response.writeline (var+ "<br/>");
}
Output results
Mokey
Tiger
School
Introduction to the use of the Split function in C #