乱数 [英] reagarding the numbers

查看:72
本文介绍了乱数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您告诉我如何检查文本框中是否显示数字?
谢谢,

can you please tell me how to check whether the numbers are presented in the textbox or not?
thanks,

推荐答案

您还可以使用Contains属性,该属性用于返回一个值,该值指示是否指定的String对象
You can also use Contains property which is used to returns a value indicating whether the specified String object
bool res =textBox1.Text.Contains("your Value"); // res will contain true if values is present 


这就是您要寻找的

Is this what you are looking for

//assuming a textbox named textbox1

int anInteger;
anInteger = Convert.ToInt32(textBox1.Text);//get the text as an integer

//or 
anInteger = int.Parse(textBox1.Text); //try to parse the value as an integer


另一种方法可能是


another method is possibly

var match = textBox1.Text.IndexOfAny("1234567890".ToCharArray()) != -1


这篇关于乱数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆