Use of string segmentation, use of string segmentation
String agentInfo = userInfo. Attribute19.ToString ();
String [] myAgent = agentInfo. Split (new string [] {"$ #$"}, StringSplitOptions. None );
If (myAgent. Length = 3)
{
This. QLookUpMyAgent. Text = myAgent [0]. ToString ();
This. QCalenderStartDate. Value = myAgent [1]. ToString ();
This. QCalenderEndDate. Value = myAgent [2]. ToString ();
}
Use the following method in VS2003:
1. Separated by strings:
Using System. Text. RegularExpressions;
String str = "aaajsbbbjsccc ";
String [] sArray = Regex. Split (str, "js", RegexOptions. IgnoreCase );
Foreach (string I in sArray) Response. Write (I. ToString () + "<br> ");
Output result:
Aaa
Bbb
Ccc
2. Separate multiple characters:
String str = "aaajbbbscccjdddseee ";
String [] sArray = str. Split (new char [2] {'J','s '});
Foreach (string I in sArray) Response. Write (I. ToString () + "<br> ");
Output result:
Aaa
Bbb
Ccc
Ddd
Eee
3. Separate them with a single character:
String str = "aaajbbbjccc ";
String [] sArray = str. Split ('J ');
Foreach (string I in sArray) Response. Write (I. ToString () + "<br> ");
Output result:
Aaa
Bbb
Ccc