C# - NullReferenceException when trying to give a value through constructor : <p>When I am trying to give value to a variable which is (should be) an object of another class DataContext through constructor it's always a null and I get a NullReferenceException. When I am trying to this by set accessor everything works fine.</p>

<pre><code>public class DataRepository
{
    private DataContext data;
    private AnyFiller currentFiller;

    public AnyFiller CurrentFiller
    {
        get
        {
            return currentFiller;
        }
        set
        {
            this.currentFiller = value;
        }
    }

    public DataContext Data { get; set; }

    public DataRepository()
    {
        this.data = new DataContext();
    }

    public DataRepository(DataContext data)
    {
        this.data = data;
    }
</code></pre>

<p>neither one of constructors works fine, but as I said before, it's working when I am doing something like this:</p>

<pre><code>        DataContext cont = new DataContext();
        DataRepository data = new DataRepository();
        data.Data = cont;
</code></pre>

<p>Could anybody tell me what am I doing wrong?</p>
