如何将此字符串列表转换为用引号括起来的逗号分隔值,而不包含任何转义字符?
{"apple", "berry", "cherry"} => well, ""apple", "berry", "cherry""
答案 0 :(得分:1)
如果我理解正确的话,
"\"" + String.Join("\", \"", new string[]{"apple","berry","cherry"}) + "\"";
或者,
String.Format("\"{0}\"", String.Join("\", \"", new string[] {"apple","berry","cherry"}));
答案 1 :(得分:0)
希望这能完成这项工作
var ar = new []{ "apple", "berry", "cherry" };
var separator = "\",\"";
var enclosingTag = "\"";
Console.WriteLine ( enclosingTag + String.Join(separator, ar) + enclosingTag );
答案 2 :(得分:0)
如果您使用的是C#:
using System;
string[] arr = new string[] { "apple", "berry", "cherry" };
string sep = "\",\"";
string enclosure = "\"";
string result = enclosure + String.Join(sep, arr) + enclosure;