如何识别一个字符串是多少? [英] How do I identify if a string is a number?

查看:97
本文介绍了如何识别一个字符串是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有这些字符串:


  1. ABC =


  2. 123 = 真正


  3. AB2 =


是否有一个命令,就像IsNumeric函数或别的东西,它可以识别一个字符串是一个有效的数字?


解决方案

  INT N;
布尔ISNUMERIC = int.TryParse(123,走出N);

If I have these strings:

  1. "abc" = false

  2. "123" = true

  3. "ab2" = false

Is there a command, like IsNumeric or something else, that can identify if a string is a valid number?

解决方案

int n;
bool isNumeric = int.TryParse("123", out n);

这篇关于如何识别一个字符串是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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