Warm tip: This article is reproduced from serverfault.com, please click
c#

c#-不可调用成员不能像方法一样使用?

(c# - Non-invocable member cannot be used like a method?)

发布于 2013-08-08 20:43:09

我的程序中不断出现以下错误:

'System.Windows.Forms.TextBox.Text' is a 'property' but used like a 'method'

Non-invocable member 'System.Windows.Forms.Control.Text' cannot be used like a method.

这是代码:

if (OffenceBox.Text != "")
   {
 AddBook(int.Parse(AgeBox.Text), NameBox.Text, AddressBox.Text, (HeightBox.Text), OffenceBox.Text());
   }
   else
   {
   MessageBox.Show("Age must be max 3 numbers in length");
   }
   }

我该如何解决这个问题?

编辑:修复了错误,现在遇到了另一个: Argument 4: Cannot convert String to int我似乎无法解决问题。

Questioner
Angelrawzz
Viewed
11
pattermeister 2013-08-09 04:44:26

在你编写“OffenceBox.Text()”的地方,你需要将其替换为“OffenceBox.Text”。这是一个属性,而不是一个方法 - 线索在错误中!