title: C# moving auto generated code to better structure code
body: <p>I am pretty new to C# and wondered if there was a simple way to move the auto-generated code to a separate class file?  </p>
  
  <p>For example, if I create a windows form onto which I drag a button. Then if I double click the button it auto generates a click event handler under the main Form1 namespace and class. Is there a way that I can move this code to a separate file (maybe a class.cs file) if I want to structure my code in a neat way rather than having an ever growing main?? </p>
  
  <p>All of the quick and dirty 'Hello World' style C# examples just show you how to add items to the form in the way described above... they don't seem to go into best practises on how to structure large code developments where structuring code into separate files can beneficial. Is what am am thinking of necessary or do developers use the standard click handlers (left in the main form) and then use that to call external reference files containing the classes/methods???</p>
  
  <p>I'd be interested if you guys can steer me in the correct direction on the best practices people use to structure large C# form based projects</p>
  
  <p>Many thanks</p>
  
  <p>Michael</p>