Join list of string to comma separated and enclosed in single quotes

后端 未结 6 1170
旧时难觅i
旧时难觅i 2021-02-03 19:41
List test = new List();
test.Add(\"test\'s\");
test.Add(\"test\");
test.Add(\"test\'s more\");
string s = string.Format(\"\'{0}\'\", string.J         


        
6条回答
  •  猫巷女王i
    2021-02-03 19:46

    I like a version without Replace:

    using System.Linq;
    (...)
    string s = String.Join(", ", from l in MyList select String.Format("'{0}'", l));
    

提交回复
热议问题