Home
Options

C# String.Split() method isn't behaving itself

edited March 2017
I'm trying to test some code with String.Split(), and it's trying to force me to only use a single-character char array, and it won't accept the option System.StringSplitOptions parameter at all.

For instance, this sample code from MSDN fails because "<<" and "..." are multi-character char arrays:
void Main()
{
char[] separatingChars = { "<<", "..." };

string text = "one<<two......three<four";
System.Console.WriteLine("Original text: '{0}'", text);

string[] words = text.Split(separatingChars, System.StringSplitOptions.RemoveEmptyEntries);
System.Console.WriteLine("{0} substrings in text:", words.Length);

foreach (string s in words)
{
System.Console.WriteLine(s);
}
}

Comments

Sign In or Register to comment.