title: Recursion with "out parameter" in C#
body: <p>Can I use an <code>out</code> parameter with a recursive method? If it's possible, how can I do it with the following code?</p>
  
  <pre><code>private void PrepareDir(out List&lt;_File&gt; listFiles,string root,string dirPath) {
      DirectoryInfo dirRoot = new DirectoryInfo(dirPath);
      FileInfo [] Files = dirRoot.GetFiles();
      dirPath = dirPath.Substring(root.Length);
  
      foreach (FileInfo file in Files) {
          _File _file = new _File();
          _file.Name = dirPath + "\\" + file.Name;
          _file.Path = file.FullName;
          _file.Size = file.Length;
          listFiles.Add(_file);
      }
  
      foreach (DirectoryInfo dir in dirRoot.GetDirectories()) {
          PrepareDir(out listFiles, root, dir.FullName);
      }
  }
  
  private void btnButton1_Click(object sender, EventArgs e) {
      List&lt;_File&gt; Files = new List&lt;_File&gt;();
      PrepareDir(out Files,currAddress, currAddress);
  }
  </code></pre>