试试看public static string FormatStr(this string str,int len)

解决方案 »

  1.   

    form["user"] 这个必需是string类型 如果不是那自己改一下相应的
     public static class ExtenObj
        {
            public static string FormatStr(this string str, int len) //把这里的string改成你对应的类型也行
            {
                string temp = "";
                temp = Regex.Replace(str, "[-*(){}';,/!\\[\\]%@]", "");            if (len != 0)
                    temp.Substring(0, len);            return temp;
            }
        }