#error
This page is specific to:.NET Framework Version:1.12.03.03.54.0
C# Programmer's Reference
#error

#error lets you generate an error from a specific location in your code.

#error text

where:

text
The text of the error that should appear in the compiler's output.

Remarks

A common use of #error is in a conditional directive. It is also possible to generate a user-defined warning with #warning.

Example

// preprocessor_error.cs
// CS1029 expected
#define DEBUG
public class MyClass 
{
   public static void Main() 
   {
      #if DEBUG
      #error DEBUG is defined
      #endif
   }
}

See Also

C# Preprocessor Directives

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View