本帖最后由 wangfei19781125 于 2010-09-26 12:28:16 编辑

解决方案 »

  1.   

    string str;
    str = str.Substring(0, 6) + "***" + str.Substring(str.Length - 4, 4);
      

  2.   


        public static class Utils
        {
            public static string Desensitize(this string str) {
                Debug.Assert(str.Length > 12);
                StringBuilder sb = new StringBuilder();
                sb.Append(str, 0, 6);
                sb.Append('*', str.Length - 13);
                sb.Append(str, str.Length - 7, 7);
                return sb.ToString();
            }
        }   private void button1_Click(object sender, EventArgs e) {
                string str = "1111111111111";
                MessageBox.Show(str.Desensitize());
            }   
      

  3.   

    string str="";
    str = str.Substring(0, 6) +new string('*',str.length-10)+ str.Substring(str.Length - 4);
      

  4.   

    string a;
    a.Replace(a.Substring(6, a.Length - 10), "*");
      

  5.   

    string result = Regex.Replace("abcdefghijklmnopqrstuvwxyz", "(?<=^.{6}).+(?=.{4})", delegate(Match m) { return new string('*', m.Length); });
      

  6.   

    for(i=6;i<str.length-4;i++)
    {
    str.Replace(str[i],'*');
    }
      

  7.   

    str = str.Substring(0, 6) + "***" + str.Substring(str.Length - 4, 4);