Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Example
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.