How Visual Studio hides compilation warnings

Source: Internet
Author: User

Recently in the development of a system in C #, using to Lucene.Net, because the loaded source version is too old, compile will be reported many warnings, but does not affect the correct execution of the code. Efforts have been made to discover the following two ways to remove compilation warnings.

1, because it is for the entire project to hide the compilation warning, so you can in the project properties of the "Generate" tab in the "Suppress warning" field to enter the warning number you need to hide, separated by commas between multiple numbers. See:


2, if you need to hide the warning of a class, you can use the #pragma warning disable preprocessing command, multiple warning numbers that need to be hidden are separated by commas, and if you do not follow any numbers, hide all warnings. As shown in the following:

#pragma warning Disable 618,414public class lucenehelper{    int i = 0;//CS0414: Field "VME. Lucene.lucenehelper.i "is assigned, but its value has never been used}

you can use the #pragma warning restore preprocessing command to restore the warning. #pragma warning command is only valid for the current CS file.




How Visual Studio hides compilation warnings

Related Article

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.