コンパイラ エラー CS1955Compiler Error CS1955
実行不可能なメンバー 'name' をメソッドのように使用することはできません。Non-invocable member 'name' cannot be used like a method.
メソッドとデリゲートだけを呼び出すことができます。Only methods and delegates can be invoked. このエラーは、空のかっこを使用してメソッドまたはデリゲート以外のものを呼び出そうとすると生成されます。This error is generated when you try to use empty parentheses to call something other than a method or delegate.
このエラーを解決するにはTo correct this error
- 式からかっこを削除します。Remove the parentheses from the expression.
例Example
次のコードでは、コードが呼び出し式 ()
を使用してフィールドとプロパティを呼び出そうとしているため、CS1955 が生成されます。The following code generates CS1955 because the code is trying to invoke a field and a property by using the invocation expression ()
. フィールドまたはプロパティを呼び出すことはできません。You cannot call a field or a property. 格納する値にアクセスするには、メンバーアクセス式 .
を使用します。Use the member access expression .
to access the value it stores.
// cs1955.cs
class A
{
public int x = 0;
public int X
{
get { return x; }
set { x = value; }
}
}
class Test
{
static int Main()
{
A a = new A();
a.x(); // CS1955
a.X(); // CS1955
// Try this line instead:
// int num = a.x;
}
}