为什么仅抑制我的一个编译器警告?

时间:2018-09-07 07:31:13

标签: c# visual-studio visual-studio-2015 compiler-warnings suppress-warnings

这是我的“抑制警告”设置在Project Properties -> Build中的样子:

enter image description here

然而,编译器似乎唯一忽略的警告是第一个警告CS0168。我仍然有很多CS0414警告:

enter image description here

为什么编译器不会忽略CS0414

1 个答案:

答案 0 :(得分:1)

不包括警告代码的前缀;只需包括数字部分。

enter image description here

nowarn compiler option documentation

也就是说,在VS Enterprise 2017中,无论是否带有前缀,它都可以使用。

另一种想法是确保在发出这些警告的项目中隐藏代码。