Change type of property in derived class I'm using manually implemented properties to handle sharing code between forms intended to edit a base object, and those intended to edit a derived version.  My current setup works as long as everyone accesses the property and not the base object; but after spending an hour or so tracking down a bug that was due to manipulating _editDataObject in DataObjectEditForm in an application using DataObjectEx and DataObjectExEditForm I'm wondering if there's a way to enforce this more strongly than just adding a do not use comment on _editDataObject.

For contractual reasons the simple option of creating a single form that is aware of both DataObject and DataObjectEx isn't permissible.

public class DataObject
{
    //data members go here
}

public class DataObjectEx : DataObject
{
    public DataObjectEx(DataObject dataObject)
    {
         //create DataObjectEx containing all of dataObject's state.
    }

    //additional data members go here
}

public class DataOjectEditForm : Form
{
    ///&lt;Summary&gt;
    ///Do not use.  Will break app if EditDataObject property is overridden.
    ///&lt;/Summary&gt;
    private _editDataObject;

    protected virtual EditDataObject
    { 
        get { return _editDataObject; }
        set { _editDataObject = value; }
    }

    //Do stuff only dependent on DataObject 
}


public class DataOjectExEditForm : DataObjectEditForm
{
    private _editDataObjectEx;

    protected override EditDataObject
    { 
        get { return _editDataObjectEx; }
        set 
        {
            if (value == null)
               _editDataObjectEx = null;
            else _editDataObjectEx = value as DataObjectEx ?? new DataObjectEx(value);
        }
    }

    //Add stuff dependent on the additions in DataObjectEx
}
Judging from the code you provided, the program is behaving as if you are using the new keyword.  This causes your property to behave differently based upon whether your form is used in the context of type DataObjectEditForm versus type DataObjectExEditForm.

To clarify:

var form = new DataObjectExEditForm ();
form.EditDataObject = new DataObjectEx ();

DataObjectEditForm  baseForm = form;
var  data = baseForm.EditDataObject;  // data = null!?!


From the looks of it, you should instead be using virtual/override on your property.  

public class DataOjectEditForm : Form
{
    protected DataObject _editDataObject;

    protected virtual DataObject EditDataObject
    { 
        get { return _editDataObject; }
        set { _editDataObject = value; }
    }

    //Do stuff only dependent on DataObject 
}


public class DataOjectExEditForm : DataObjectEditForm
{
    protected override DataObject EditDataObject
    { 
        get { return _editDataObject; }
        set 
        {
            if (value == null)
               _editDataObject = null;
            else _editDataObject = value as DataObjectEx ?? new DataObjectEx(value);
        }
    }

    //Add stuff dependent on the additions in DataObjectEx
}


Of course, that is only going to guarantee that the backing field used by the form is consistent.  If the bug is the result of _editDataObject being used in some contexts while _editDataObjectEx was used in other contexts, then this will solve your issue.