title: Invalid token 'while' in class, struct, or interface member declaration in very simple code
body: <p>I am not sure what the problem is but I keep receiving this error when I try to use a while statement in my code.</p>
  
  <blockquote>
    <p>Invalid token 'while' in class,
    struct, or interface member
    declaration</p>
  </blockquote>
  
  <p>I want to use a while loop to have something continuously update while a statement is true.</p>
  
  <p>The rest of my code is rather long but whenever I type in the syntax:</p>
  
  <pre><code>while(a&lt;b)
  {
  //do whatever i want it to do here
  }
  </code></pre>
  
  <p>It gives me that compiler error right off the bat. Not quite sure what the problem is. I am doing this in a C# windows application under the Form1.cs file with all the other event handlers (for buttons and such). 
  Thanks!</p>
  
  <hr>
  
  <p>I was unaware that loops had to be placed within a method (fairly new to c#), but I tried it and no errors were returned. Thanks for your help everybody!</p>
  
  <p>Previously, I just had the loop within the main class of the program.</p>