分割字符串并按照预想格式合并
public static string FormatSearchFieldOfMutiValue(string vSearchValue) { var rtn = ""; vSearchValue = vSearchValue.Trim(); vSearchValue = vSearchValue.Replace("'", "''"); var array = vSearchValue.Split(new char[] { ',', ',', ';', ';', '+', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length > 0) { rtn = "'" + string.Join("','", array.Where(n => n != "")) + "'"; } else { rtn = "''"; } return rtn; }
本文来自博客园,作者:LI小白,转载请注明原文链接:https://www.cnblogs.com/LittleBai/p/12786313.html