title: Linq How to Get Average When all values equals null or 0 ? MVC
body: <p>When my model has values, i can get the average easily with this code</p>
  
  <pre><code>@Model.Where(a =&gt; a.count!= null).Average(a =&gt; a.totalday).ToString()
  </code></pre>
  
  <p>For example:</p>
  
  <blockquote>
    <p>count = 7 totalday= 3 average= 2.33</p>
  </blockquote>
  
  <p>But i can't get average value when my model values equals to null or zero. As you know we can't divide 0 to 0 or null to null.</p>
  
  <p>I mean;</p>
  
  <blockquote>
    <p>count = 0 or null; totalday= 0 or null; average= ????</p>
  </blockquote>
  
  <p>If all values are null, how can i write my table to "0" or a string like "there is no any average"</p>
  
  <p>I tried lots of things but i get an error.</p>