Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS0243
Collapse the table of content
Expand the table of content

Compiler Error CS0243

The Conditional attribute is not valid on 'method' because it is an override method

The Conditional 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 (C# Programming Guide).

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 sample 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() {}

Community Additions

© 2015 Microsoft