如果要检查数字的if条件是C#.net代码后面的浮点数或整数代码 [英] an if condition to check the number is float or integer code in C#.net code behind

查看:68
本文介绍了如果要检查数字的if条件是C#.net代码后面的浮点数或整数代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查Result = 3.44444
然后检查Resultint还是float form

I want to check if Result = 3.44444
then check Result is int or float form

推荐答案

如果数据类型od Resultstring:

使用int32 TryParse 方法 [
If the data type od Result is string:

Use the int32 TryParse method[^] or the float TryParse method to figure out the type of your value.

E.g. bool result = Int32.TryParse(Result, out number);

So you can use
if (Int32.TryParse(Result, out number))
{
  //Then value is integer 
}


这篇关于如果要检查数字的if条件是C#.net代码后面的浮点数或整数代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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