title: Check for null in razor view
body: <p>I'm sending this viewmodel to a view:</p>
  
  <pre><code>public class ViewModelProductCategory
  {
      public int Id { get; set; }
      public int? ParentId { get; set; }
      public string Title { get; set; }
      public int SortOrder { get; set; }
      public IEnumerable&lt;ViewModelProductCategory&gt; Children { get; set; }
      public List&lt;ViewModelProduct&gt; Products { get; set; }
      public List&lt;ViewModelProduct&gt; OrphanProducts { get; set; }
  }
  </code></pre>
  
  <p>This is the (partial) view:</p>
  
  <pre><code>@foreach (var item in Model)
  {
      &lt;li&gt;
          @item.Title (@item.Products.Count) // this causes problems if num of products = 0.
          &lt;ul&gt;
              @Html.Partial("_CategoryRecursive.cshtml", item.Children)
          &lt;/ul&gt;
      &lt;/li&gt;
  }
  </code></pre>
  
  <p>Sometimes a product category don't have any products, and that causes a null reference exeption when I try to count them. How can I check for that?</p>