title: Creating a string array with a 'foreach' loop in C#
body: <p>I slightly altered some code from msdn.com. I'm trying to get a string array of all the sheet names in an Excel spreadsheet. Can I add some code to the <code>foreach</code> statement so that each time it loops, it places attr.Value into the array?</p>
  
  <pre><code>public static void GetSpreadsheetData(string fileName)
  {
      using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(fileName, false))
      {
          string[] allTheSheets = new string[0];
          string[] allTheData = new string[0];
          S sheets = spreadsheetDocument.WorkbookPart.Workbook.Sheets;
  
          foreach (E sheet in sheets)
          {
              foreach (A attr in sheet.GetAttributes())
              {
                  int i = 0;
                  string sheetName = attr.Value;
                  allTheSheets[i] = attr.Value.ToString();
                  i++;
                  Console.WriteLine(allTheSheets[0]);
                  Console.ReadLine();
              }
          }
      }
  }
  </code></pre>
  
  <p>Here is the error message I'm getting:</p>
  
  <blockquote>
    <p>"Index was outside the bounds of the array."</p>
  </blockquote>
  
  <p>One of the things that has me confused is that when I instantiated the array, I gave it an index of [0], so how is that outside the bounds?</p>