要检查字符串值是否具有数值或不是在C# [英] To check whether the string value has numeric value or not in C#

查看:69
本文介绍了要检查字符串值是否具有数值或不是在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的字符串

I am having an string like this

字符串str =dfdsfdsf8fdfdfd9dfdfd4

string str = "dfdsfdsf8fdfdfd9dfdfd4"

我需要通过数组循环来检查字符串是否包含数字。

I need to check whether the string contains number by looping through the array.

推荐答案

有关定期EX pression什么:

What about a regular expression:

bool val = System.Text.RegularExpressions.Regex.IsMatch(str, @"\d");

这篇关于要检查字符串值是否具有数值或不是在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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