title: C#: recursively replace characters in a string
body: <p>I have a string <code>"abcdef"</code> I want to change recursively. If a character <code>cha</code> is found, all characters up to this should be replaced with another character, <code>chb</code>
  Ex.
  If <code>cha = 'd'</code>, the modified string becomes "xxxxef" (if <code>chb = 'x'</code>).
  If <code>cha = 'g'</code>, the string shouldn't be changed.</p>
  
  <p>This is what I've tried</p>
  
  <pre><code>string myString = "abcdef";
  char[] str = myString.ToCharArray();
  void FindInString(int p)
  {
     if (p &lt; str.Length-1)
     {
        if (str[p] != cha)
           FindInString(p + 1);
     }
     str[p] = chb;
  }
  </code></pre>
  
  <p>What I don't understand about recursitivity is what's happening on it's way back, ie. how to write a condition for the line</p>
  
  <pre><code>str[p] = chb;
  </code></pre>