title: A button click event in IF ELSE loop
body: <p>I want to trigger a BUTTON_CLICK event IF the condition("file.length()&lt;0") is true. I tried as follows but I am getting error as "WindowsFormsApplication1.Form1.info is a 'field' but used as a 'type' ".
  Can you give your inputs please. Thank you.</p>
  
  <pre><code>namespace WindowsFormsApplication1
  {
  
      public partial class Form1 : Form
      {
          private  int flag;
          public Form1()
          {
              InitializeComponent();
  
          }
  
  
           FileInfo info = new FileInfo("c:\\test.txt");
              if (info.Length &gt; 0)  // throws an error "invalid token if in class"
                  flag= 1;             //throws an error "WindowsFormsApplication1.Form1.info               
                                         is a 'field' but used as a 'type' "  
                                       //similar error for flag as for info
  
      if(flag==1) //similar error for flag as for info
      {
  
      private void button1_Click(object sender, EventArgs e)
          {
              //Code for Redirection to New Form
  
  
          }
      }
      }
  }
  </code></pre>