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

  • Remove the parentheses after expression 'name'.

Example

The following code generates CS1955 because the code is trying to invoke a field and a property by using the method call operator (). You cannot call a field or property, but you can access the value it stores by using the member access operator ( . ).

namespace CompilerError1955
{
    class ClassA
    {
        public int x = 100;
        public int X
        {
            get { return x; }
            set { x = value; }
        }
    }

    class Test
    {
        static void Main()
        {
            ClassA a = new ClassA();
            // a.x is an integer.
            System.Console.WriteLine(a.x()); // CS1955
            // a.X is a property.
            System.Console.WriteLine(a.X()); // CS1955
            // Try these lines instead:
            //System.Console.WriteLine(a.x);
            //System.Console.WriteLine(a.X);
            //int num = a.x;
        }
    }
}

Change History

Date

History

Reason

June 2010

Expanded the example.

Customer feedback.

August 2008

Added explanatory text.

Customer feedback.