无法将方法组转换为非委托类型'bool'
问题描述:
完整错误: 无法将方法组'CombinationCheck'转换为非委托类型'bool'。你打算采用这种方法吗?无法将方法组转换为非委托类型'bool'
我正在尝试使用bool中的值来确定文本框的值,但似乎无法解决如何操作。任何帮助是极大的赞赏,我得到的错误从(CombinationCheck)
bool CombinationCheck(string combination)
{
if (combination.Length > 5)
return true;
else
return false;
}
和
if (CombinationCheck)
text_SafeStatus.Text = "Combination Set";
else
text_SafeStatus.Text = "Combination Not Set";
答
CombinationCheck
是一种方法,这需要一个(字符串)参数。所以你不能单靠名字来引用它。您必须包含必需的字符串参数(combination
)。
if (CombinationCheck(someString))
text_SafeStatus.Text = "Combination Set";
else
text_SafeStatus.Text = "Combination Not Set";
或
text_SafeStatus.Text =
CombinationCheck(someString)? "Combination Set":
"Combination Not Set";
我已经在你前面的问题回答了这个.. – abdul