转换字符串格式,可用于sql in

  /// <summary>
        /// 转换字符串格式,可用于sql in
        /// </summary>
        /// <param name="lst"></param>
        /// <returns></returns>
        public static string ParseToSQLIn(string lst)
        {
            StringBuilder sb = new StringBuilder();
            string[] array = lst.Split(',');
            //sb.Append("'0'");
            foreach (string item in array)
            {
                sb.Append(",'");
                sb.Append(item);
                sb.Append("'");
            }
            if (sb.Length > 0)
            {
                sb.Remove(0, 1);
            }
            return sb.ToString();
        }

 

posted on 2015-05-06 15:01  雪原日暮  阅读(694)  评论(0编辑  收藏  举报