Compiler error CS0243
The Conditional attribute is not valid on 'method' because it is an override method
The ConditionalAttribute attribute is not allowed on a method that is marked with the override keyword. For more information, see Knowing When to Use Override and New Keywords.
The compiler never binds to override methods. It only binds to the base method, and the common language runtime calls the override, as appropriate.
The following code generates CS0243:
// CS0243.cs
// compile with: /target:library
public class MyClass
{
public virtual void M() {}
}
public class MyClass2 : MyClass
{
[System.Diagnostics.ConditionalAttribute("MySymbol")] // CS0243
// remove Conditional attribute or remove override keyword
public override void M() {}
}
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