Compiler Error CS0119
'construct1_name' is a 'construct1', which is not valid in the given context.
The compiler detected an unexpected construct such as the following:
A class constructor is not a valid test expression in a conditional statement.
A class name was used instead of an instance name to refer to an array element.
A method identifier is used as if it were a struct or class
The following sample generates CS0119: 'C.B()' is a method, which is not valid in the given context. You can fix this error by changing the name of the method C.B
, or using the fully qualified name for the class B
like N2.B
.
namespace N2
{
public static class B
{
public static void X() {}
}
}
namespace N1
{
public class C
{
void B() {}
void M() => B.X(); // CS0119
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: