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 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.
// 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;
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for