'int,tryparse(stringm out int)'的最佳重载方法匹配包含一些无效参数

编程入门 行业动态 更新时间:2024-10-10 17:29:56
本文介绍了'int,tryparse(stringm out int)'的最佳重载方法匹配包含一些无效参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你能帮我解决这个错误 参数1:无法从'十进制'转换为'字符串'

if ( int .TryParse(numericUpDownLowerLimit.Value , out MINLENGTH)== false || int .TryParse(numericUpDownUpperLimit.Value, out MAXLENGTH)== false ) { ShowErrorBox( 最小和最大长度必须是有效整数。); return ; }

解决方案

NumericUpDown的Value属性不是字符串 - 它是 decimal value,所以你不需要尝试解析它。 同样,它可以设置为始终是一个有效的整数,方法是将DecimalPlaces属性保留为零 - 所有你需要做的是将其转换为 int

NumericUpDown的值始终是十进制,绝不是字符串。因此,您需要将其转换为int:

int MINLENGTH =( INT )numericUpDownLowerLimit.Value; int MAXLENGTH =( int )numericUpDownUpperLimit.Value;

Can you help me with this error Argument 1: cannot convert from 'decimal' to 'string'

if (int.TryParse(numericUpDownLowerLimit.Value, out MINLENGTH) == false || int.TryParse(numericUpDownUpperLimit.Value, out MAXLENGTH) == false) { ShowErrorBox("Min and Max lengths must be valid integers."); return; }

解决方案

The Value property of a NumericUpDown is not a string - it's a decimal value, so you don;t need to try and parse it. Equally, it can be set to be always a valid integer by leaving the DecimalPlaces property at zero - all you need to do then is cast it to an int

The value of a NumericUpDown is always a decimal, never a string. So you'll need to cast it to an int:

int MINLENGTH = (int)numericUpDownLowerLimit.Value; int MAXLENGTH = (int)numericUpDownUpperLimit.Value;

更多推荐

'int,tryparse(stringm out int)'的最佳重载方法匹配包含一些无效参数

本文发布于:2023-06-03 07:25:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/471225.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   方法   int   stringm   tryparse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!