title: How does C# understand an .txt file as output for the main?
body: <p>The following code in the main is written: </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO;
  namespace text_test
  {
  class Program
  {
      static void Main(string[] args)
       {
         txt_program tt = new txt_program();
          string[] output_txt = tt.txt;
      }
  }
  }
  </code></pre>
  
  <p>An error appears:</p>
  
  <blockquote>
    <p>stating cannot convert method group 'txt' to non-delegate type 'string[]'.</p>
  </blockquote>
  
  <p>Instead of <code>string[]</code> what should I write? The called code looks like this: </p>
  
  <p>(same system calls as the above).</p>
  
  <pre><code>namespace text_test
  {
  
  class txt_program
  
  {
      public void txt(string[] args)
      {
          // Take 5 string inputs -&gt; Store them in an array
          // -&gt; Write the array to a text file
  
          // Define our one ad only variable
          string[] names = new string[5]; // Array to hold the names
  
          string[] names1 = new string[] { "max", "lars", "john", "iver", "erik" };
  
          for (int i = 0; i &lt; 5; i++)
          {
              names[i] = names1[i];
          }
  
          // Write this array to a text file
  
          StreamWriter SW = new StreamWriter(@"txt.txt");
  
          for (int i = 0; i &lt; 5; i++)
          {
              SW.WriteLine(names[i]);
          }
  
          SW.Close();
      }
  }
  }
  </code></pre>