I have a string where there are single quotes (') and would like to split
but by setting, ''');
, it breaks the code.
splitString = splitLines[i].Split(' ', ',', ';', '"', '(', ')', '!', '?', ':', '…', '„', '“', '¿', '¡');
I have a string where there are single quotes (') and would like to split
but by setting, ''');
, it breaks the code.
splitString = splitLines[i].Split(' ', ',', ';', '"', '(', ')', '!', '?', ':', '…', '„', '“', '¿', '¡');
As it stands you will generate a syntax error.
You can give a scape \'
:
string[] resultado = x.Split(new char[] { '\'' }, StringSplitOptions.None);
Console.WriteLine(String.Format("Resultado: {0},{1}", resultado[0], resultado[1]));
Or instead of passing a char array as a parameter you can use string:
string[] resultado2 = x.Split(new string[] { "'" }, StringSplitOptions.None);
Console.WriteLine(String.Format("Resultado2: {0},{1}", resultado2[0], resultado2[1]));
Example Online: .Net Fiddle
Method Split