本文介绍了'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 intThe 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)'的最佳重载方法匹配包含一些无效参数
发布评论