Monday 9 July 2012

String.Split does not support splitting by a string

error: The best overloaded method match for 'string.Trim(params char[])' has some invalid arguments

 

Lets say I have a multiline TextBox that I want to split into an array of String objects, each containing a line from the TextBox.

A logical way to do this would be:
String[] s = textBox1.Text.Split("\r\n");

This does not work.

A workaround is to use this:

String[] s = textBox1.Text.Split("\r\n".ToCharArray());

No comments:

Post a Comment