You are using double quotes, which is the literal of string
. That one Overload of the method Split
expecting a char
. Use simple quotes this way:
string[] caminho = path.Split('/');
Of documentation:
Char constants can be written as literals of
characters, hexadecimal escape sequence or as representation
Unicode. You can also convert the character codes
integral. In the following example, four char variables are
initialized with the same character X:
char[] chars = new char[4];
chars[0] = 'X'; // Character literal
chars[1] = '\x0058'; // Hexadecimal
chars[2] = (char)88; // Cast from integral type
chars[3] = '\u0058'; // Unicode
foreach (char c in chars)
{
Console.Write(c + " ");
}
// Output: X X X X
Tochararray wouldn’t do either?
string[] caminho = path.Split("/".ToCharArray());
– Pablo Tondolo de Vargas
@Pablotondolodevargas and vnbrs: the
Split
has override forchar[]
also, but it wouldn’t make any sense to use it when you can just change the quotes. The answer gives the best way for sure.– Jéf Bueno