C # tutorial # define and # undef [original]

Source: Internet
Author: User

# Define allows you to define symbols. When you use a symbol as the expression passed to the # if Command, the calculation result of this expression is true. # Undef is the opposite. It allows you to cancel the definition of a symbol, so that the expression is calculated as false by using the symbol as an expression in the # if command.

The definition method is keyword + space + symbol to be defined, for example

# Define DEBUG // declarative DEBUG

# Undef DEBUG // Delete the DEBUG symbol

It tells the compiler that there is a given name symbol. In this example, the defined symbol is DEBUG. This is similar to declaring a variable, but the variable itself does not have a real value, but it only exists. This symbol is not part of the actual code, but exists only when the compiler compiles the code. In C # code, it makes no sense.

Note the following three points:

1. If the symbol already exists, the declaration will be meaningless. Similarly, if the symbol does not exist, deleting the page does not work.

2. In addition, the pre-processing command does not need to end with a semicolon. It considers that only one command is available in one line.

3. The declaration must be at the top of the class category.

Xiaotian: What is the purpose of this? Not shown.

This article is a new one. For more information, see the source and author!

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.