C#实现把String字符串转化为SQL语句中的In后接的参数
程序员文章站
2022-04-29 13:03:41
实现把String字符串转化为In后可用参数代码: public string StringToList(string aa) { string bb1 = "("; if (!string.IsNullOrEmpty(aa.Trim())) { string[] bb = aa.Split(new ......
实现把string字符串转化为in后可用参数代码:
public string stringtolist(string aa) { string bb1 = "("; if (!string.isnullorempty(aa.trim())) { string[] bb = aa.split(new string[] { "\r\n", ",", ";", "* " }, stringsplitoptions.removeemptyentries); for (int i = 0; i < bb.length; i++) { if (!bb1.contains(bb[i]))//去掉重复的輸入值 { bb1 += "'" + bb[i] + "',"; } } } bb1 = bb1.substring(0, bb1.lastindexof(",")) + ")"; return bb1; }