如何编写从(文本框)读取文本的代码,当我按下我的(按钮)时,它会删除文本中的所有点?

How do I write a code that reads a text from the (textbox) and when I press my (button) it delets all DOTS in the Text?

我有 2 个文本框。一种用于您可以粘贴的文本,一种用于为您提供相同的文本但其中没有任何点。

有很多方法可以做到这一点。

1 种简单方法

  private void TextBox1_TextChanged(object sender, EventArgs e)
{
    TextBox2.Text = TextBox1.Text;
    TextBox2.Text = TextBox2.Text.Replace(".", "");
}

您可以在单行中编写以上代码来替换文本框值。

private void TextBox1_TextChanged(object sender, EventArgs e)
{
    TextBox2.Text = TextBox1.Text.Replace(".", "");
}