title: Rewrite this array manipulation using a lambda function?
body: <p>I have this routine which alters all elements within an array...</p>
  
  <pre><code>    for (int i = 0; i &lt; sOutputFields.GetUpperBound(0); i ++)
      {
          sOutputFields[i] = clsSQLInterface.escapeIncoming(sOutputFields[i]);
      }
  </code></pre>
  
  <p><code>sOutputFields</code> is a one dimensional <code>string</code> array. <code>escapeIncoming()</code> is a function which returns a <code>string</code>.</p>
  
  <p>I thought this could be re-written thus..</p>
  
  <pre><code>    sOutputFields.Select(el =&gt; clsSQLInterface.escapeIncoming(el));
  </code></pre>
  
  <p>..but this appears to do nothing (though does not throw an exception). So I tried..</p>
  
  <pre><code>    sOutputFields = 
         (string[])sOutputFields.Select(el =&gt; clsSQLInterface.escapeIncoming(el));
  </code></pre>
  
  <p>..but I get this exception at execution time..</p>
  
  <p><strong>"Unable to cast object of type 'WhereSelectArrayIterator`2[System.String,System.String]' to type 'System.String[]'."</strong></p>
  
  <p>how to fix?</p>