title: How do I add code outside the scope of Main when using C# 9 Top Level Statements?
body: <p>My understanding is that it is similar to write code directly into the old &quot;<code>static void Main(string[] args)</code>&quot; without the need to display what's above.</p>
  <p>However, I used to declare my variables in the class Program to have them accessible from other classes (apologies if not best practice, I learnt C# by myself and as long as it works, I'm happy with my code).
  See example below:</p>
  <pre><code>using System.Text;
  using System.Threading;
  using System.Threading.Tasks;
  using System.IO;
  
  namespace myNameSpace
  {
      class Program
      {
          //variables declaration
          public static string abc = &quot;abc&quot;;
          public static int xyz = 1;
  
          static void Main(string[] args)
          {
              //code goes here
          }
      }
  }
  </code></pre>
  <p>With C# 9, it seems I can only declare variables in the Main section, so how can I declare them to be able to access them from other classes?</p>