用String.Substring()和String.Replace()相结合

解决方案 »

  1.   

    String.Substring(4,3).Replace(eiio,1234);
      

  2.   

    String s1="abcdeiioooof3943n";
    String s2=s1.Substring(4,3);
    s1=s1.Replace(s2,"1234");
    MessageBox.Show(s1);
      

  3.   

    chinchy(人民需要人民币) :
         你的方法有点问题。
    String s1="abcdeiioooof3943n";
    String s2=s1.Substring(4,3);
    s1=s1.Replace(s2,"1234");
    MessageBox.Show(s1);如果我要替换字符串在原字符串中出现多次,那岂不是所有字符串都要替换?但我仅替换一个。
      

  4.   

    哪就用这种形式吧
    ================================
    String s="abcdeiioooof3943n";
    s=s.Substring(0,3)+"1234"+s.Substring(6,s.Length-7);
      

  5.   

    chinchy(人民需要人民币) :
           你这方法感觉不是还好,有没有其他更好的方法呢?
      

  6.   

    用 chinchy(人民需要人民币)的方法,自己写个函数
      

  7.   

    String str="abcdeiioooof3943n";
    str = str.Substring(0, 3) + "1234" + str.Substring(7);除了这个真的想不出更好的方法:)
      

  8.   


    //用Remove和Insert:string str="abcdeiioooof3943n";
    str=str.Remove(3,3);
    str=str.Insert(3,"1234");