title: How can I convert @helper function to a partial view I call?
body: <p>I have this @helper function in a Helpers.cshtml file located under ~/App_Code:</p>
  
  <pre><code>@helper TempCost(Decimal cost)
  {
  @: @String.Format("{0:C0}", cost)
  }
  </code></pre>
  
  <p>That I would have used thusly in my view:</p>
  
  <pre><code>@Helpers.TempCost(Model.PriceInformation.MyPrice)
  </code></pre>
  
  <p><code>PriceInfrormation</code> is my model, and <code>MyPrice</code> is a property within (decimal).</p>
  
  <p>I now want to put this helper in it's own partial view. I can call the partial view and pass the arguments with no problem. However, I do not know how to get the code in the partial view to work.</p>
  
  <p>I tried something like:</p>
  
  <pre><code>@{
  decimal cost;
  }
  @String.Format("{0:C0}", cost)
  </code></pre>
  
  <p>but am getting the following error:</p>
  
  <blockquote>
    <p>error CS0165: Use of unassigned local variable 'cost'</p>
  </blockquote>
  
  <p>Sorry, not a programmer by profession. Appreciate any help.</p>