title: String Utilities in C#
body: <p>I'm learning about string utilities in C#, and I have a method that replaces parts of a string.</p>
  
  <p>Using the replace method I need to get an output such as</p>
  
  <p>"Old file name: file00"</p>
  
  <p>"New file name: file01"</p>
  
  <p>Depending on what the user wants to change it to.</p>
  
  <p>I am looking for help on making the method (<code>NextImageName</code>) replace only the digits, but not the file name.</p>
  
  <pre><code>class BuildingBlock
  {
      public static string ReplaceOnce(string word, string characters, int position)
      {
          word = word.Remove(position, characters.Length);
          word = word.Insert(position, characters);
          return word;
      }
  
      public static string GetLastName(string name)
      {
          string result = "";
          int posn = name.LastIndexOf(' ');
          if (posn &gt;= 0) result = name.Substring(posn + 1);
          return result;
      }
  
      public static string NextImageName(string filename, int newNumber)
      {
          if (newNumber &gt; 9)
          {
              return ReplaceOnce(filename, newNumber, (filename.Length - 2))
          }
          if (newNumber &lt; 10)
          {
  
          }
          if (newNumber == 0)
          {
  
          }
      }
  </code></pre>
  
  <p>The other "if" statements are empty for now until I find out how to do the first one.</p>