An uncommon but useful preprocessing command: # pragma warning

Source: Internet
Author: User
During team development, every time the latest version of the project file is obtained through the version control software and compiled, the vs Error List will always display the following prompts:

Although the project is compiled and runs normally, it is uncomfortable to see several or even dozens of hundreds of warnings in different projects each time. Lou pig is a bitCodeIf the project was not very tight, and the project was very energetic and time-consuming, Jie Li would also stick to his perfectionist preferences to the end, so he could not help but boldly refactor the code in other projects, however, it is sometimes found that such warnings are a "slow strategy" for other developers, such as the following code:

Internal void dosomething () {try {// some code here for doing something} catch (exception ex) {// throw ex; // to do write exception logs }}

After analyzing the dosomething function, we found that the developer has already marked "to do" in the exception handling area. It may be because it has not been processed for some reason, appropriate code will be added in the future development. The warning information can be properly blocked by pre-processing commands (refer to msdn) without affecting the function:

Internal void dosomething () {# pragma warning disabletry {// some code here for doing something} catch (exception ex) {// throw ex; // to do write exception logs }}

Only one row# Pragma warning disableAnd the warning information is gone. If you need to complete the code in the future, find the command or "to do" mark through the vs search function.

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.