Check if a string has at least one number in it using LINQ

后端 未结 5 977
既然无缘
既然无缘 2020-12-04 21:07

I would like to know what the easiest and shortest LINQ query is to return true if a string contains any number character in it.

5条回答
  •  死守一世寂寞
    2020-12-04 21:23

    string number = fn_txt.Text;   //textbox
            Regex regex2 = new Regex(@"\d");   //check  number 
            Match match2 = regex2.Match(number);
            if (match2.Success)    // if found number 
            {  **// do what you want here** 
                fn_warm.Visible = true;    // visible warm lable
                fn_warm.Text = "write your text here ";   /
            }
    

提交回复
热议问题