小编JaJ*_*aJa的帖子

为什么警告禁用429无法抑制无法访问的代码?

我试图在一个非常简单的C#文件中抑制警告,但是它无法正常工作,我找不到我在这里做错了什么.为什么Visual Studio仍会在这一小段代码中显示"无法访问的代码".

#pragma warning disable 429

// I've got the number from:
// http://msdn.microsoft.com/en-us/library/2ch1a3w5.aspx

// This below does work, so I might have the wrong number for the warning?
// #pragma warning disable 

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("test");
            if (false)
                return;
            return;
            MessageBox.Show("test");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# pragma compiler-warnings

1
推荐指数
1
解决办法
1421
查看次数

标签 统计

c# ×1

compiler-warnings ×1

pragma ×1