实现效果:

知识运用:

代码实现:
private void button1_Click(object sender, EventArgs e)
{
if (IsValidate(textBox1.Text.ToString()))
MessageBox.Show("验证通过","提示:");
else
MessageBox.Show("验证失败", "提示:");
}
//方法定义
public bool IsValidate(string str_decimal) {
return System.Text.RegularExpressions.
Regex.IsMatch(str_decimal,@"^[0-9]+\.[0-9]{2}$");
}
原文:https://www.cnblogs.com/feiyucha/p/9978034.html