title: Delete Selected Text from Textbox and Enter New Char in C#.NET
body: <p>I am trying to delete selected text from textbox and enter new character in place of it. 
  For example, if textbox consists of <code>123456</code> and I select <code>345</code>, and press <kbd>r</kbd> on the keyboard, it should replace the selected text.</p>
  
  <p>here is my code:</p>
  
  <pre><code>string _selectText = txtCal.SelectedText;
  string _text = Convert.ToString(btn.Text);
  
  if (_selectText.Length &gt; 0) {
     int SelectionLenght = txtCal.SelectionLength;
     string SelectText = txtCal.Text.Substring(txtCal.SelectionStart, SelectionLenght);
     txtCal.Text = ReplaceMethod(SelectText, _text);
  }
  
  //replace method function
  public string ReplaceMethod(string replaceString, string replaceText) {
     string newText = txtCal.Text.Replace(replaceString, replaceText);
     return newText;
  }
  </code></pre>
  
  <p>Can anyone show me where my mistake is?</p>