Possible mistaken empty statement warning

I’m new to coding and I’ve been having warning with all day with “If (Jtag.activeConnection);” It gives me “Possible mistaken empty statement”. It doesn’t effect my program but every video I’ve seen people never get that warning and I would like to just clear It. The following is my code

public partial class Form1 : MetroFramework.Forms.MetroForm
{
    XRPC Jtag = new XRPC();
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        Jtag.Connect();
        if (Jtag.activeConnection) ;
    }
}

Answer

Well, your if statement is empty

if (Jtag.activeConnection) ;

So the compiler is asking you to confirm if that’s really what you wanted to do.

Normally it should be something like

if (Jtag.activeConnection)
{
  // do something
}

Leave a Reply

Your email address will not be published. Required fields are marked *