用逗号分隔c#中的多个字符串
本文关键字:字符串 分隔 | 更新日期: 2023-09-27 18:07:17
row来自csv文件,比如
"abc@example.com","seattle,US","9999 00000"
预期输出:abc@example.com
seattle,US
9999 00000
执行string.Split(',')
时的实际输出:
"abc@example.com"
"seattle
US"
"9999 00000"
如果您使用"
字符来限定列,则可以使用","
string input = "'"abc@example.com'",'"seattle,US'",'"9999 00000'"";
string[] result = input.Trim('"').Split(new string[] { "'",'"" }, StringSplitOptions.None);