Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C#
C# Reference
 #error

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
C# Language Reference
#error (C# Reference)

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

#error Deprecated code in this method.

A common use of #error is in a conditional directive.

It is also possible to generate a user-defined warning with #warning (C# Reference).

// preprocessor_error.cs
// CS1029 expected
#define DEBUG
class MainClass 
{
    static void Main() 
    {
#if DEBUG
#error DEBUG is defined
#endif
    }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker