Site icon Sibeesh Passion

Split method with a string value in c#

As you know a normal split method is accepting only a character . It will throw an error when we give a string to split. This code shows you how you can use split method to split a string by a string in c#.
[csharp]
string myQuery="select * from tblAccount where id=1"
List<string> queryList = myQuery.Split(new string[] { "where" }, StringSplitOptions.None).ToList();
[/csharp]
The queryList will give you the list after split

Kindest Regards

Exit mobile version