7
I am creating a program in C# that reads a text file and one of the lines of that file has the following format:
'Column 1' 'Column 2' 'Column 3'
I want to turn that line into one array of strings so that the answer looks like this:
    Colunas[0] = "Coluna 1"
    Colunas[1] = "Coluna 2"
    Colunas[2] = "Coluna 3"
That is, I want it to identify each string within an apostrophe and store it in the array. I tried to do this by reading the whole line using the following code:
    string Linha = Leitor.ReadLine(); //Leitor é o StreamReader que lê o arquivo
And then I tried the method linha.Split
    var NomesColunas = linha.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
But then the result was as follows: {"Column", "1", "Column", "2", "Column", "3" }. I tried to use the apostrophe as char to do Split but is giving compilation error, I’m not hitting the syntax.
How did your
Split? Edit your answer and put it there, it’s better than in the comments, I think.– Willian
Thanks for the tip! I put there, I think it was better explained.
– Carlos Eduardo
What a most inconvenient file format...
– Genos