title: ForEach Loop to txt
body: <p>My <code>foreach</code> loops through a List, and I need the loop to write itself to a text file in a form like this:</p>
  
  <pre><code>[
    {
      "Platillo": "Pozole",
      "PDV": "Restaurante",
      "Turno": "matutino",
      "PV": "$45.00",
      "1": "1",
      "2": "1"
    },]
  </code></pre>
  
  <p>My foreach loop fills a html table at the moment.</p>
  
  <pre><code> foreach (var item in Model)
  {
      var total = 0;
      decimal costo = 0;
  
      for (int i = 1; i &lt;= 31; i++)
      {
          var value = 0;
          if (item.Fecha.Day == i) { value = item.Cantidad; costo = costo + item.Total; }
          total += value;
      }
      &lt;tr&gt;
          &lt;td class="descripcion"&gt;@item.Descripcion&lt;/td&gt;
          &lt;td class="pdv"&gt;@item.Pdv&lt;/td&gt;
          &lt;td class="pdv"&gt;@item.Rid&lt;/td&gt;
          &lt;td&gt;@((costo / (total + 1)).ToString("C"))&lt;/td&gt;
          @for (int i = 1; i &lt;= 31; i++)
          {
              var value = 0;
              int month = item.Fecha.Month;
              if (item.Fecha.Day == i) { value = item.Cantidad; }
  
          }
          &lt;td&gt;@total&lt;/td&gt;
          &lt;td&gt;@(((costo / (total + 1)) * total).ToString("C"))&lt;/td&gt;
  </code></pre>
  
  <p>How do I do this in columns, and do that for every item in my <code>foreach</code> statement?</p>