Reputation: 667
I'm trying split a string in CRM using different characters (like whitespace, comma, period, colon, semicolon, slash, pipe). But I also need to split on a new line as well.
The below function is working to split using different characters:
string[] values = propertylist.Split(new Char[] { ' ', ',', '.', ':','\t', '/', ';', '|', '\\', '\r', '\n'});
I read that for new line the symbol must be '\r\n'.. but for some reason if I change the function a little bit from Split(new Char[] to Split(new String[], even after changing to use double quotation mark, I keep getting error "Cannot convert from string[] to char[]..." even though I am already using double quotation mark.
Any suggestions for this is appreciated very much. Thanks!
-elisabeth
Upvotes: 0
Views: 73
Reputation: 66459
Most likely you changed the code in your question to this:
string[] values =
propertylist.Split(new string[] { " ", ... "\r", "\n"});
The problem is that the method overload that accepts a string[]
requires additional parameters. Without supplying those parameters, you get a syntax error.
This is the closest match for your original code:
string[] values =
propertylist.Split(new string[] { " ", ... "\r\n"}, StringSplitOptions.None);
Upvotes: 0