How do I recognize a particular type of quotation mark set in C#?

This question is a result from the question asked here:

It seems that quotation marks are not all the same.  How would I parse through different sets of quotation marks?  I use a StreamReader to read a file "C:\sample.csv" into a string "buffer" (line by line), then split this string by commas.

How can I detect the particular set of commas that are open (\\), straight (||), and closed (//)?
using (StreamReader reader = new StreamReader("C:\\sample.csv")) {
                string buffer;
                // Iterate through all lines
                while ((buffer = reader.ReadLine()) != null) {
                    string[] lineValues = buffer.Split(',');
                                    // Find the value with the first set of quotation marks
/**** EXPERTS-EXCHANGE - this is not picking up my expected set of question marks! ****/.
                                    while (!lineValues[i].Contains("\"")) 

Open in new window

Who is Participating?
hyliandannyConnect With a Mentor Author Commented:
I found the problem.  Perhaps it will help you all avoid any similar mistakes in the future.

The sample format was given to me in a Microsoft Word document.  Consequently, when creating the CSV data sample I would test with, I copied and pasted the quotation mark characters within the sample from Microsoft Word into notepad.

This embellished, MS-Word-specific character is NOT equivalent to the quotation marks in the code.  That is why it was never picking it up.
string delimeter = ",";
StreamReader reader = new StreamReader(file);
//read the first line in and split it into columns
string[] columns = reader.ReadLine().Split(delimeter.ToCharArray());
hyliandannyAuthor Commented:
Even using the delimiter, as HarryNS suggested, results in the data being read as:

" Joeý "

where the ý is actually a pair of quotation marks...
hyliandannyAuthor Commented:
Althought it is "ý" in the comments, that copy/paste is actually a square when viewed in the debugger.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.