C # error and warning message directives

Source: Internet
Author: User

Precompilation and conditional compilation directives can help us to emit compiled errors or warnings during the execution of the program, the corresponding instructions are #warning and #error, and the following programs show their usage.

Program Listing 8-7:

#define DEBUG
#define RELEASE
#define DEMO version
#if demo version &&! Debug
  #warning are building a demo version
#endif
#if Debug && demo version
  #error you cannot Build a debug demo version
#endif

using System;
Class Demo
{public
  static void Main ()
  {
    Console.WriteLine ("Demo Application");
  }
This article is published in www.bianceng.cn (programming entry Network)

In this case, when you try to create a demo version, a warning message appears:

You are building a demo version

An error message is triggered when you try to create a debug demo:

Cannot build a debug demo version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.