如题:

解决方案 »

  1.   

    用正则表达式 
    if(Regex.IsMatch(inputString, "[^\\d,]")){
    {
      //Invalid chars found
    }
    else
    {
      //valid chars only found
    }
      

  2.   

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 46 && e.KeyChar != 8 && e.KeyChar != 13)
                {
                    //.......
                    e.Handled = true;
                }
                else {
                    e.Handled = false;
                }        }
      

  3.   

    用正则表达式该怎么写?aspirant12(大兵) 是对的!