Compiler Error CS1511
Keyword 'base' is not available in a static method
The base keyword was used in a static method. base
can only be called in an instance constructor, instance method, or instance accessor.
Example
The following sample generates CS1511.
// CS1511.cs
// compile with: /target:library
public class A
{
public int j = 0;
}
class C : A
{
public void Method()
{
base.j = 3; // base allowed here
}
public static int StaticMethod()
{
base.j = 3; // CS1511
return 1;
}
}
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