Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error CS0578 

Error Message

The Conditional attribute is not valid on 'function' because its return type is not void

ConditionalAttribute cannot be applied to a method that has a return type other than void. The reason for this is that any other return type for a method may be needed by another part of your program.

Example

The following sample generates CS0578. To resolve this error, you must either delete ConditionalAttribute, or you must change the return value of the method to void.

// CS0578.cs
// compile with: /target:library
public class MyClass
{
   [System.Diagnostics.ConditionalAttribute("a")]   // CS0578
   public int TestMethod()
   {
      return 0;
   }
}

Community Additions

ADD
Show:
© 2015 Microsoft