title: C# add values to a Dictionary using a loop
body: <p>I'm using EasyPost(shipping API) to get shipping rates.</p>
  
  <p>I'm able to hard code the shipments but that doesn't help me. I need to add data based on what the user selects.</p>
  
  <p>Below is the code I have. As you can see I have two shipments that are currently hard coded. I'd like to remove the hard coded shipments and add a loop around it and add shipments that way. I can pass the package type and weight myself through variables.</p>
  
  <p>So if the user has 5 packages I would like to add 5 shipments.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>List&lt;Dictionary&lt;string, object&gt;&gt; shipments;
  
   shipments = new List&lt;Dictionary&lt;string, object&gt;&gt;() {
              new Dictionary&lt;string, object&gt;() {
                  {"parcel", new Dictionary&lt;string, object&gt;() {{ "predefined_package", "MediumFlatRateBox" },  { "weight", 5 }}}
              },
              new Dictionary&lt;string, object&gt;() {
                  {"parcel", new Dictionary&lt;string, object&gt;() {{ "predefined_package", "LargeFlatRateBox" },  { "weight", 15 }}}
              }
          };
  parameters = new Dictionary&lt;string, object&gt;() {
              {"to_address", toAddress},
              {"from_address", fromAddress},
              {"reference", "USPS"},
              {"shipments", shipments}
                   };
  
  Order order = Order.Create(parameters);
  </code></pre>