This is for split string with a char as delimiter:

string input = "hello_world_this_is_me";
var output = input.Split("_");

For split it with a string as delimeter:

string input = "hello_:_world_:_this_:_is_:_me";
var output = input.Split(new string[] { "_:_" }, StringSplitOptions.None);

The second parameter can be StringSplitOptions.None or StringSplitOptions.RemoveEmptyEntries: with the value StringSplitOptions.RemoveEmptyEntries, the return value does not include array elements that contain an empty string.

Advertisements