Powered by Blogger.

Monday, July 10, 2017

How to split a string by another string in C#.Net?




Here we will see how we can split a string by another string in C#.Net. Here in the below example we have string like "This is for our site and we need this for our project". And we want to split with the string "our".

Below is the code:

string myString = "This is for our site and we need this for our project";


string[] ourSplitArr= myString.Split(new string[] { "our" }, StringSplitOptions.None);

The above Split function will return a string array like below:


You can use the above arrary for your requirement. Hope this will be helpful.



0 comments

Post a Comment