title: C# Replace all characters in string with X except spaces
body: <p>I'm making a hangman game in C#, and it needs to show the player the sentence, but with ALL characters as an "X", EXCEPT a space with a space. So if the sentence is "I'm a person" it would be "XXX X XXXXXX". I have found a way to do this when EVERY character replaces with "X", but the problem is that, spaces is also replaced with X. </p>
  
  <p>The code:</p>
  
  <pre><code>string WrVS = String.Empty;
  for (int i = 0; i &lt; Words[randomVal].Length; i++)
  {
      WrVS += "X";
  }
  RWordCensored.Text = WrVS;
  </code></pre>
  
  <p>(randomVal is the random number that selects a random sentence from a list),
  (RWordCensored is a richTextBox that should show the sentence in the format I said.</p>
  
  <p>I haven't found an answer on Google to my question.</p>
  
  <p>/Viktor</p>