In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to use C# preprocessor instructions. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article, let's take a look at it.
1.#warning and # error:
When the compiler encounters them, it generates warnings or errors, respectively. If the compiler encounters the # warning instruction, it displays the text after the # warning instruction to the user, and the compilation continues. If the compiler encounters the # error instruction, it will display the following text to the user as a compilation error message, and then immediately exit the compilation. Use these two instructions to check if the # define statement has done something wrong, and use the # warning statement to remind yourself to perform an action.
# if DEBUG & & RELEASE # error "You've defined DEBUG and RELEASE simultaneously!" # endif # warning "Don't forget to remove this line before the boss tests the code!" Console.WriteLine ("* I hate this job.*")
2. # region and # endregion
The # region and # endregion directives mark a piece of code as a block with a given name, as follows:
# region Member Field Declarationsint xternal double dexterous currency balance;#endregion
This doesn't seem to work, and it doesn't affect the compilation process. The advantage of these instructions is that they can be recognized by some editors, including the Visual Studio .NET editor. These editors can use these instructions to make the code better laid out on the screen.
3. # line
The # line directive can be used to change the file name and line number information displayed by the compiler in warning and error messages, which is not commonly used.
You can use this directive if you want to use some software package to change the entered code before writing code before sending it to the compiler. because this means that the line number or file name reported by the compiler does not match the line number in the file or the edited file name. The # line directive can be used to restore this match. You can also use the syntax # line default to restore the line number to the default line number:
# line 164" Core.cs "/ / restore the default line number on line 164 / / Core.cs, before the intermediate// package mangles it.// later on#line default / / of the file
4. # pragma
The # pragma directive suppresses or restores specified compilation warnings. Unlike command-line options, # pragma instructions can be executed at the class or method level, providing finer control over the content and duration of suppression warnings. As follows:
# pragma warning disable 169cancel warning (field unused warning) public class MyClass {int neverUsedField; / / do not issue warning when compiling the entire MyClass class} # pragma warning restore 169warning / restore the warning above is all the content of this article "how to use C# preprocessor instructions". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.