C# #pragma 警告禁用代码列表及其含义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/942238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:52:44  来源:igfitidea点击:

List of #pragma warning disable codes and what they mean

c#c-preprocessorpragma

提问by Garrett

The syntax for disabling warnings is as follows:

禁用警告的语法如下:

#pragma warning disable 414, 3021

Or, expressed more generally:

或者,更一般地表达:

#pragma warning disable [CSV list of numeric codes]

Is there a list of these numeric codes and the description of the warning that they're suppressing? Much to my chagrin, I can't seem to locate it via Google.

是否有这些数字代码的列表以及它们抑制的警告的描述?令我懊恼的是,我似乎无法通过 Google 找到它。

采纳答案by Joe White

You shouldn't need a list. The compiler will tell you. If you get a compiler error that says "warning CS0168", then add 168 to the list (or, better yet, fix the code).

你不应该需要一个列表。编译器会告诉你。如果您收到一个编译器错误,提示“警告 CS0168”,则将 168 添加到列表中(或者,更好的是,修复代码)。

回答by Jeffrey Hantin

Look down the list of C# compiler errors and warningsto find the individual warning numbers.

查看C# 编译器错误和警告列表以查找各个警告编号。

回答by MiffTheFox

MSDN has a listof warning codes. Unfortunately, you have to click each link to view what the code actually means.

MSDN 有一个警告代码列表。不幸的是,您必须单击每个链接才能查看代码的实际含义。

回答by Syndog

FYI -

供参考 -

If you're using Visual Studio 2008, you can get the code directly from the Error Listby right-clicking the error, and selecting Show Error Helpfrom the context menu. The Help window should pop up, and show you everything you ever wanted to know about the error a la the MSDN website.

如果您使用的是 Visual Studio 2008,您可以通过右键单击错误并从上下文菜单中选择显示错误帮助直接从错误列表中获取代码。应该会弹出帮助窗口,并显示您想知道的关于 MSDN 网站上的错误的所有信息。

Could save you a bit of time.

可以为你节省一点时间。