创建像IsDigit()这样的函数 [英] Create a function like IsDigit()
本文介绍了创建像IsDigit()这样的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Doeas知道创建此类函数的最简单方法:
bool result = IsDigit(string s);
Sam
解决方案
sk *** **@gmail.com schrieb:
Doeas知道创建此类函数的最简单方法:
bool result = IsDigit(string s);
Sam
你的意思是数字''0'','' 1'',..'''9'',这是一个(或更好的九个)
简单的相等操作,还是数字?如果,哪个数字? int,double?
听起来像家庭作业;)
Tobi
你可以使用int.TryParse或检查strign中的每个字符是否为
a数字:
foreach(char c in string s)
if!char.IsDigit(c)
返回false
返回true;
Calum。
1月11日下午1点09分,skne ... @ gmail.com写道:
Doeas任何人都知道创建此类函数的最简单方法:
bool result = IsDigit(string s);
Sam
sk*****@gmail.com 写道:
Doeas知道创建此类函数的最简单方法:
bool result = IsDigit(string s);
使用正则表达式。像[0-9] +这样简单的东西应该工作。
克里斯。
Doeas any know the simplest way for create this type of function:
bool result = IsDigit(string s);
Sam
解决方案
Hi,
sk*****@gmail.com schrieb:Doeas any know the simplest way for create this type of function:
bool result = IsDigit(string s);
Samdo you mean digit like ''0'', ''1'', .. ''9'', which is a (or better nine)
simple equal operations, or number? If, which numbers? int, double?
Sounds like homework ;)
Tobi
You can use int.TryParse or check that each character in the strign is
a digit:
foreach(char c in string s)
if !char.IsDigit(c)
return false
return true;
Calum.
On Jan 11, 1:09 pm, skne...@gmail.com wrote:Doeas any know the simplest way for create this type of function:
bool result = IsDigit(string s);
Sam
sk*****@gmail.com wrote:Doeas any know the simplest way for create this type of function:
bool result = IsDigit(string s);Use a regular expression. Something simple like "[0-9]+" should work.
Chris.
这篇关于创建像IsDigit()这样的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文