我得到這個錯誤 「對象引用不設置到對象的實例。」
public class Chromosome
{
public int[] gen;
public void abad(int nn)
{
gen = new int[nn];
}
public int fit;
}
public void button1_Click(object sender, EventArgs e)
{
Chromosome[] chorm;
int ab;
ab = Convert.ToInt16(txtab.Text);
int ehtemal;
ehtemal = Convert.ToInt16(txtehtemal.Text); //ehtemal jahesh gen
int nokhbe;
nokhbe = Convert.ToInt16(txtnokh.Text);
int tedad;
num = Convert.ToInt16(txtnum.Text);
chorm = new Chromosome[tedad + 1];
for (int xx = 0; xx < tedad; xx++)
chorm[xx].abad(ab);
int ad = tedad;
int row = 0 ,col = 0 ;
}
for (int z = 0; z < ab; z++)
temp.gen[z] = chorm[i].gen[z];
錯誤發生在線路chorm[xx].abad(ab)
和最後兩行
非常感謝你 – 2012-03-05 12:33:08