Compiler Error CS0154
The property or indexer 'property' cannot be used in this context because it lacks the get accessor
An attempt to use a property failed because no get accessor method was defined in the property. For more information, see Fields.
The following sample generates CS0154:
// CS0154.cs
public class MyClass2
{
public int i
{
set
{
}
// uncomment the get method to resolve this error
/*
get
{
return 0;
}
*/
}
}
public class MyClass
{
public static void Main()
{
MyClass2 myClass2 = new MyClass2();
int j = myClass2.i; // CS0154, no get method
}
}
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.
.NET feedback
.NET is an open source project. Select a link to provide feedback: