Whats wrong with this for loop?http://forums.asp.net/t/1782378.aspx/1?Whats+wrong+with+this+for+loop+Mon, 19 Mar 2012 16:25:27 -040017823784887881http://forums.asp.net/p/1782378/4887881.aspx/1?Whats+wrong+with+this+for+loop+Whats wrong with this for loop? <p>whats the problem with the following code, its giving me tough time for almost half a day.</p> <pre class="prettyprint">if ((extImage != null)) { string[] ast_url = null; ast_url[0] = &quot;&quot;; ast_url[1] = &quot;&quot;; ast_url[2] = &quot;&quot;; ast_url[3] = &quot;&quot;; ast_url[4] = &quot;&quot;; for (int i = 0; i &lt; 5; i&#43;&#43;) { if (extImage[i] != null) { asset link = extImage[i]; ast_url[i] = link.url; } }</pre> 2012-03-19T16:11:33-04:004887885http://forums.asp.net/p/1782378/4887885.aspx/1?Re+Whats+wrong+with+this+for+loop+Re: Whats wrong with this for loop? <p>Is it not compiling or is it not producing the correct result? It it hanging?</p> 2012-03-19T16:13:47-04:004887889http://forums.asp.net/p/1782378/4887889.aspx/1?Re+Whats+wrong+with+this+for+loop+Re: Whats wrong with this for loop? <p>its giving the following error</p> <p>Object reference not set to an instance of an object.</p> <p></p> <p>When I remove the empty string assignments, then it gives another error of object refernce not set to an instance of an object</p> 2012-03-19T16:16:08-04:004887902http://forums.asp.net/p/1782378/4887902.aspx/1?Re+Whats+wrong+with+this+for+loop+Re: Whats wrong with this for loop? <p>Change:</p> <pre class="prettyprint">string[] ast_url = null; to</pre> <pre class="prettyprint"><span class="pln"></span><span class="kwd">string</span><span class="pun">[]</span><span class="pln"> ast_url </span><span class="pun">=</span><span class="pln"> new string[5]</span><span class="pun">;</span><span class="pln"><br /><br /></span></pre> 2012-03-19T16:25:27-04:00