String 转为 List

String 转为 List

   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].Trim() + "',";
                }
            }
        }
        bb1 = bb1.Substring(0, bb1.LastIndexOf(",")) + ")";
        return bb1;
    }

 

posted @ 2021-05-04 14:35  码农阿亮  阅读(1324)  评论(0编辑  收藏  举报