I have an error in my c# code
<p>I have a class and two objects from this class. I want to copy an object to another object with this code but I get this error:</p>

<blockquote>
  <p>Object reference not set to an instance of an object.</p>
</blockquote>

<p>The error happens in last line. What should I do?</p>

<pre><code>public class Chromosome
        {
            public int[] gen;
            public void abad(int nn)
            {
                gen = new int[nn];
            }
            public int fit; 
        }
int ab = int .parse(txtnum.Text);
Chromosome [] chrom =new Chromosome[10];
Chromosome temp=new Chromosome ();
for (int xx = 0; xx &lt; 10; xx++)
            {
                chorm[xx] = new Chromosome();
                chorm[xx].abad(ab);
            }
 for (int i = 0; i &lt; 5; i++)
            {
                for (int z = 0; z &lt; ab; z++)
                temp.gen[z] = chorm[i].gen[z];
            }
</code></pre>
