C#:检查存储字符串对象中的值是十进制或不 [英] C# : Check value stored inside string object is decimal or not

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

问题描述

在C#中,我怎么能检查是否保存在里面的字符串对象的值(例:串strOrderId =435242A)是小数或不?

in C# , how can i check whether the value stored inside a string object( Ex : string strOrderId="435242A") is decimal or not?

推荐答案

使用的 Decimal.TryParse 功能

decimal value;
if(Decimal.TryParse(strOrderId, out value))
  // It's a decimal
else
  // No it's not.

这篇关于C#:检查存储字符串对象中的值是十进制或不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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