title: Manipulation of list to create extra calculated column
body: <p>I have this program that reads a .txt file and creates a <code>List&lt;Class&gt;</code>. This class has 10 "columns". See image below</p>
  
  <p><a href="https://i.stack.imgur.com/QFRBn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QFRBn.png" alt="enter image description here"></a></p>
  
  <p>The Total UoM column is not in the .txt file but I would like to create this extra column as an additional column in my collection. So the last column in the text file is Width.</p>
  
  <p>Calculation should be as follows:</p>
  
  <p>For rows where Width = 0, Total UoM should be Qty * Length (Ignore Net Weight)</p>
  
  <p>For rows where Width > 0, Total UoM should be Qty * Length * Width</p>
  
  <p>Code thus far:</p>
  
  <pre><code>// Structure of SteelAssembly Class object
    public class SteelAssembly
    {
        public int LotNo { get; set; }
        public string AssemblyMark { get; set; }
        public string AssemblyName { get; set; }
        public string Part { get; set; }
        public int Quantity { get; set; }
        public string Profile { get; set; }
        public string Grade { get; set; }
        public decimal Length { get; set; }
        public decimal Weight { get; set; }
        public decimal Width { get; set; }
    }
  </code></pre>
  
  <p>...............</p>
  
  <pre><code> lines = new List&lt;string&gt;();
                          assembly = new List&lt;SteelAssembly&gt;();
  
                          // Open the text file using a stream reader.
                          using (StreamReader sr = new StreamReader(openFileDialog.FileName))
                          {
                              // Read the stream to a string, and write the string to the console.
                              while (sr.Peek() &gt;= 0)
                                  lines.Add(sr.ReadLine());
                          }
  
                          // Read job number
                          jobNumber = lines.FirstOrDefault();
  
                          // Remove job number from list
                          lines.Remove(jobNumber);
                          if (lines.Count &gt; 0)
                          {
                              try
                              {
                                  foreach (string row in lines)
                                  {
                                      // Split the columns of the .txt document
                                      string[] words = row.Split(new[] { "  " }, StringSplitOptions.RemoveEmptyEntries);
  
                                      // Remove all null or empty rows
                                      if (words != null || words.Length != 0)
                                      {
                                          // Transform data to SteelAssembly Class object
                                          assembly.Add(new SteelAssembly
                                          {
                                              LotNo = Convert.ToInt32(words[0]),
                                              AssemblyMark = words[1].Trim(),
                                              AssemblyName = words[2].Trim(),
                                              Part = words[3].Trim(),
                                              Quantity = Convert.ToInt32(words[4]),
                                              Profile = words[5].Trim(),
                                              Grade = words[6].Trim(),
                                              Length = Convert.ToDecimal(words[7]),
                                              Weight = Convert.ToDecimal(words[8]),
                                              Width = Convert.ToDecimal(words[9]),
                                          });
                                      }
                                  }
                              }
  </code></pre>
  
  <p>....................</p>
  
  <p>Each unique Assembly Mark/Lot No. will be a new production order so we have this dictionary</p>
  
  <pre><code>// Create dictionary         
  var dictionary = assembly
                   .GroupBy(x =&gt; new
                   {
                       x.AssemblyMark,
                       x.LotNo                                   
                   })
                   .ToDictionary(x =&gt; x.Key, x =&gt; x.ToList());
  </code></pre>
  
  <p>This transforms into:</p>
  
  <p><a href="https://i.stack.imgur.com/kFEBf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kFEBf.png" alt="enter image description here"></a></p>
  
  <p>How do I manage to get the extra column in my dictionary with the correct total UoM?</p>