The Split method from System.String doesn’t provide a simple way of splitting a String with a String delimiter. Instead it proposes to split it with a Char. Useful, but not enough…

This is the way for splitting a String based on a String delimiter:

var test = "Hello_World"; var result = test.Split(new[] { "_World" }, StringSplitOptions.None).First();
Code language: C# (cs)

Otherwise, if you just want to split the String based on a Char, you could simply use this:

var test = "Hello_World"; var result = test.Split('_').First();
Code language: C# (cs)

Both solution should give you:

result == "Hello";
Code language: C# (cs)

Happy coding! 😉