title: Initialization of C# String array
body: <p>I want to declare a string array, I was using this way of doing it</p>
  
  <pre><code>string[] matchingFiles = Directory.GetFiles(FilePath, FileNamePattern);
  </code></pre>
  
  <p>which worked perfectly, but now I want to enclose the Directory.GetFiles call in a try/catch block, but I cant also have the declaration of the string array in there because then it wont be in the right scope to use it outside of the try block. But if I try this:</p>
  
  <pre><code>string[] matchingActiveLogFiles;
              try
              {
                  matchingFiles = Directory.GetFiles(FilePath, FileNamePattern);
              }
              catch (Exception ex)
              {
                  //logerror
              }
  </code></pre>
  
  <p>I have not initialized the string array so I have an error. So I am wondering what is best practise in this situation, should I declare the string array outside the try block? And if so how?</p>