'int,tryparse(stringm out int)'的最佳重载方法匹配包含一些无效参数 [英] The Best overloaded method match for 'int,tryparse(stringm out int)' has some invalid arguments
本文介绍了'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 adecimal
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 anint
The value of aNumericUpDown
is always adecimal
, 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)'的最佳重载方法匹配包含一些无效参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文