title: Trying to set value for ViewBag
body: <p>Can someone tell me why this does not work?</p>
  
  <p>I get the error <code>No overload for method 'Write' takes 0 arguments</code>. This happens right on the first line in the foreach where I set the ViewBag.InvoiceTotal.</p>
  
  <pre><code>@foreach (var invoice in Model.Invoices)
  {
      @{ ViewBag.InvoiceTotal = (invoice.Product.Price * invoice.Quantity).ToString("c"); }
  
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; invoice.InvoiceDate)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; invoice.Company.Name)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; invoice.Product.Name)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; invoice.Quantity)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; invoice.Product.Price)
          &lt;/td&gt;
          &lt;td&gt;
              @ViewBag.InvoiceTotal
          &lt;/td&gt;
          &lt;td&gt;
              @Html.ActionLink("Edit", "Edit", new { id = invoice.InvoiceId }) |
              @Html.ActionLink("Details", "Details", new { id = invoice.InvoiceId }) |
              @Html.ActionLink("Delete", "Delete", new { id = invoice.InvoiceId })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>