title: Dictionary TryGetValue NullReferenceException
body: <p>I am getting  NullReferenceException at the <code>_dicCache.TryGetValue(objID, out newObject);</code> 
  line. And I have no Idea why this is happening at all. Can comeone point me to the right direction please?</p>
  
  <p>Here is my class:</p>
  
  <pre><code>public class Cache&lt;T&gt;
  {
      public string Name { get; set; }
  
      private  Dictionary&lt;int, T&gt; _dicCache = new Dictionary&lt;int, T&gt;();
  
      public  void Insert(int objID, T obj)
      {
          try
          {
              _dicCache.Add(objID, obj);
  
              HttpContext.Current.Cache.Insert(Name, _dicCache, null, DateTime.Now.AddMinutes(10), TimeSpan.FromMinutes(0));
          }
          catch (Exception)
          {
              throw;
          }
      }
  
      public bool Get(int objID, out T obj)
      {
          _dicCache = (Dictionary&lt;int, T&gt;)HttpContext.Current.Cache.Get(Name);
  
  
          try
          {
              return _dicCache.TryGetValue(objID, out obj);
          }
          catch (Exception)
          {
              throw;
          }
      }
   }
  </code></pre>
  
  <p>And here is how I call it:</p>
  
  <pre><code>   Services.Cache&lt;Entities.User&gt; cache = new Services.Cache&lt;Entities.User&gt;();
     cache.Name = Enum.Cache.Names.usercache.ToString();
  
  
     Entities.User user = new Entities.User();
  
     cache.Get(pUserId, out user);
  </code></pre>
  
  <p>I Also have tried to change to Get class to:</p>
  
  <pre><code>    public T Get(int objID, out T obj)
      {
          _dicCache = (Dictionary&lt;int, T&gt;)HttpContext.Current.Cache.Get(Name);
  
          T newObject = (T)Activator.CreateInstance&lt;T&gt;();
  
  
          try
          {
              _dicCache.TryGetValue(objID, out newObject);
  
              obj = newObject;
  
              return obj;
          }
          catch (Exception)
          {
              throw;
          }
      }
  </code></pre>
  
  <p>But I still get the same NullReferenceException at the <code>_dicCache.TryGetValue(objID, out newObject);</code> line.</p>