Reusing a property value from within an object initializer
<p>First of all sorry for the intriguing title of my question, hopefuly a code sample exposing my problem will clarify things.</p>

<p>Below you will find a code sample that does not compile (and I totally get why, no need to explain) but which expose what I am trying to achieve:</p>

<pre><code>public class Cmd
{
    public Byte MyByte { get; set; }
    public Byte MyOtherByte { get; set; }
    public String MyString { get; set; }

    public static Cmd FromStream(Stream stream)
    {
        return new Cmd
        {
            MyByte = (Byte)stream.ReadByte(),
            MyOtherByte = (Byte)stream.ReadByte(),
            MyString = SomeMethodBasedOnMyOtherByte(MyOtherByte) // Here
        };
    }
}
</code></pre>

<p>I hope you get the idea. Of course if the stream is seekable I could just seek back one byte and reread it for passing it as the argument of the method I am calling. But if the stream is non seekable, no way.</p>

<p>This is a very basic example of course, in my real scenario the classes on which I would like to implement FromStream have many different properties.</p>

<p>Is there any keyword that allows to do what I am trying to do, basically reusing an affected property value from within an object initializer block ?</p>

<p>If not I guess the only way for me would be not to use an object initializer in this context, and construct a new object affecting it's properties one by one (so that I can reuse affected properties if needed). And wouldn't it be nice to have (or reuse) a keyword for this specific scenario in object initializer ? If not, why ?</p>

<p>Thanks !</p>
