Possible Duplicate:
What is a NullReferenceException in .NET?
I am developing a simple program. Accepting an arraylist from Form1 and displaying its contents on form2 and I am getting this error.. Plz enlighten me.. Coding goes like this ..
FORM1.cs..............
public partial class Form1 : Form
{
    ArrayList alcar;
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        string name = textBox1.Text; ; int quantity = int.Parse(textBox2.Text);
        car c = new car(name, quantity);
        if (alcar != null)
        {
            alcar.Add(c);
        }
        else
        {
            alcar = new ArrayList();
            alcar.Add(c);
        }
        Form2 f2 = new Form2();
        f2.Show();
    }
    public ArrayList getArray()
    {
     return alcar;
    }    
}
class car
{
    string name; int quantity;
    public string NAME
    {
        get { return name; }
        set { name = value; }
    }
    public int QUANTITY
    {
        get { return quantity; }
        set { quantity = value; }
    }
    public car(string n, int q)
    {
        name = n; quantity = q;
    }
}
FORM2.cs.........................
public partial class Form2 : Form
{
    ArrayList al;
    public Form2()
    {
        Form1 f1 = new Form1();
        if (al != null)
        {
            al = f1.getArray();
        }
        else
        {
            al = new ArrayList();
            al = f1.getArray();
        }
        InitializeComponent();
        foreach (car c in al)        // this lne is causing error
        {
            label1.Text = c.NAME;
            label2.Text = Convert.ToString(c.QUANTITY);
        }
    }
}
 
     
     
     
     
     
     
     
    