Object reference not set to an instance of an object (custom class as property on a form)
<p>I have a WinForms app.</p>

<p>One of my forms has two properties which are custom classes i.e.</p>

<pre><code>private cContact con;
private cIP ip;
</code></pre>

<p>In the LOAD event for the form I initialize these properties as follows -</p>

<pre><code>this.con = new cContact();
this.ip = new cIP();
</code></pre>

<p>The parameterless Constructors for these classes simply populate the ID field and nothing else e.g.</p>

<pre><code>class cContact
{
    private int _id;
    //...plus several other properties here

    public cContact()
    {
        this._id = 0;
    }

    public int ID
    {
        get {return this._id;};
        set {this._id = value};
    }
}    
</code></pre>

<p>Both classes contain multiple properties of which ID is just one (int).</p>

<p>Both classes contain Get / Set access modifiers for all properties.</p>

<p>Both classes have been in use for over a year without any issues, so I don't think the problem I am having is with the Classes themselves.</p>

<p>Then in my form I have an Event Handler which attempts to access the IDs in the two form properties (my custom classes)</p>

<pre><code>private void Button_Click( . . .)
{
    int myID = this.con.ID
}
</code></pre>

<p>Yet I get a message saying </p>

<pre><code>Object reference not set to an instance of an object
</code></pre>

<p>As the classes are instantiated in the Form's LOAD event, I fail to see why the button click event handler cannot access the class ID field.  Pretty sure this is going to be something simply when one of you point it out, but alas its had me scratching my head for too long already.</p>
