The String.Split method returns an array of the substrings in a given string that are delimited by specified strings.
- using System;
- using System.Collections.Generic;
-
- namespace ConsoleApplication1
- {
- public class MyClass
- {
-
-
-
-
-
-
-
-
- static void Main()
- {
-
-
-
- string myQuery = "select * from Customer where Cust_id=786";
-
-
-
- string[] result;
-
-
-
-
- result = myQuery.Split(new string[] { "where" }, StringSplitOptions.None);
-
-
-
-
-
-
-
-
-
-
-
-
- string str = "";
- foreach (string s in result)
- str += s.Trim() +"\n";
-
-
- Console.WriteLine("{0}", str);
-
-
-
-
-
-
-
-
- Console.WriteLine("Result[0]= {0},\nResult[1]= {1}", result[0], result[1]);
-
-
-
-
-
-
-
-
- }
-
- }
- }