Edit

Share via


Compiler Error CS1955

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

  1. 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 invocation expression (). You cannot call a field or a property. Use the member access expression . to access the value it stores.

C#
// 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;  
    }  
}