C# C# Streams and Data Processing Parsing Data Reading Line By Line

Richard Külling
Richard Külling
8,076 Points

Why is this split(new char[]{' ', '\t'}) incorrect?

"Bummer! 'split(new char[]{' ', '\t'})' is incorrect"

...How comes that string[] words = "The quick brown fox jumped over the lazy dog".Split(new char[]{' ', '\t'}); doesn't do the job?

1 Answer

Steven Parker
Steven Parker
168,451 Points

The question says "Complete the following code to split the string by spaces into an array of strings."

I'll bet you were thinking "whitespace"; but since they are asking explicitly for spaces, it's not correct to include tabs as an additional delimiter. Also, since you only need to specify a single character, you can use a simpler form of the "Split" method.