C# Error
CS1955 – Non-invocable member ‘{0}’ cannot be used like a method.
Reason for the Error & Solution
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
The following code generates CS1955 because the code is trying to invoke a field and a property by using the . You cannot call a field or a property. Use the 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;
}
}