Immutable objects with object initialisers
<p>I have the following attempt at an immutable object:</p>

<pre><code>class MyObject
{
    private static int nextId;

    public MyObject()
    {
        _id = ++nextId;
    }

    private int _id;
    public int Id { get { return _id; } }
    public string Name { get; private set; }
}
</code></pre>

<p>Then, I try to use it like so:</p>

<pre><code>MyObject o1 = new MyObject { Name = "foo" };
</code></pre>

<p>But the object initialiser fails because <code>Name</code>'s setter is private. Is there a way around this, or do I have to choose between one or the other?</p>
