class design: How do I create a class with nested objects?
<p>I am currently developing a client library for connecting to Newegg using the documentation provided by Newegg and have a question on class design. </p>

<p>In working with various API's ( namely NetSuite and Amazon's MWS ) I come across classes that have are used like this: </p>

<pre><code> recToFulfill.packageList = new ItemFulfillmentPackageList();
 recToFulfill.packageList.package = new ItemFulfillmentPackage[ifitemlist.item.Length];
 recToFulfill.packageList.package[i] = new ItemFulfillmentPackage();
 recToFulfill.packageList.package[i].packageWeightSpecified = true;
 recToFulfill.packageList.package[i].packageTrackingNumber = "trackingNumber";
</code></pre>

<p>The question I have is: How do I <em>properly</em> design the nested objects like above? I have never had to worry about this previously, so I am unsure on where to look, or start. </p>

<p>The bit I need to figure out looks like this ( taken from the API documentation provided): </p>

<pre><code>&lt;UpdateOrderStatusInfo&gt;
    &lt;IsSuccess&gt;&lt;/IsSuccess&gt;
    &lt;Result&gt;
        &lt;OrderNumber&gt;&lt;/OrderNumber&gt;
        &lt;SellerID&gt;&lt;/SellerID&gt;
        &lt;OrderStatus&gt;&lt;/OrderStatus&gt;
    &lt;/Result&gt;
&lt;/UpdateOrderStatusInfo&gt;
</code></pre>

<p>All fields are type string, except order number which is an integer. </p>

<p>I have this currently: </p>

<pre><code> public class UpdateOrderStatusInfo
{
    public string IsSuccess { get; set; }
    public int OrderNumber { get; set; }
    public string SellerID { get; set; }
    public string OrderStatus { get; set; }
}
</code></pre>

<p>But the returned XML Response has Results as a parent node which to me seems like it should be represented within the class itself. Would I just do this?</p>

<pre><code>public UpdateOrderStatusInfo results {get; set;}
</code></pre>

<p>If so, where do the child nodes go? </p>

<p>What I need is to be able to say is something like:</p>

<pre><code>UpdateOrderStatusInfo updateInfo = new UpdateOrderStatusInfo();
if(updateInfo.IsSuccess.Equals("true")
{
     Console.WriteLine(updateInfo.Results.OrderStatus);
}    
</code></pre>

<p>Any help, or advice on where to get this information is appreciated. </p>
