I’m pretty sure that code like this adapts better to many conditions, but for a simple, fast way of parsing a CSV with values enclosed by double quotes, use Regex:
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
Show("(\"[^\"]*\")","\"hola\",\"todo,el\",\"mundo\"");
}
public static void Show(string r, string s)
{
var ms = Regex.Matches(s,r);
foreach(Match m in ms)
{
Console.WriteLine("Groups[0]:{0}",m.Groups[0]);
Console.WriteLine("Groups[1]:{0}",m.Groups[1]);
}
}
}