实现效果:

  使用正则表达式验证汉字输入

知识运用:

  使用正则表达式验证汉字输入

 

实现代码: 

        private void button1_Click(object sender, EventArgs e)
        {
            if (!textBox1.Text.Equals(string.Empty))
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(textBox1.Text, "[\u4e00-\u9fa5]{1,}"))
                    MessageBox.Show("任务完成,赏啤酒一箱", "恭喜!");
                else
                    MessageBox.Show("看来你需要的是再来一次哟!!", "细心点"); textBox1.Text = "";
            }
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-14
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2021-05-27
  • 2021-10-29
相关资源
相似解决方案