title: C# Get higest item using arrays
body: <p>I try get higest item from map, but code not working :( Hope guys know more about arrays :)</p>
  
  <p>Error:</p>
  
  <pre><code>System.NullReferenceException was caught
    HResult=-2147467261
    Message=Object reference not set to an instance of an object.
    Source=Game1
    StackTrace:
         in Game1.Map.GetTopItem(Int32 X, Int32 Y) Line 11
         in UserMovedToItem(User User, MapItem MapItem, String Extra)
    InnerException: 
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>private MapItem GetTopItem(int X, int Y)
  {
      double Height = 0.0;
      MapItem[] TopItem = null;
      foreach (MapItem @class in this.FloorItems.Values)
      {
          if (@class.Int32_0 == X &amp;&amp; @class.Int32_1 == Y)
          {
              Height += @class.Height;
              TopItem[Height] = @class;
          }
      }
      return TopItem.Max();
  }
  </code></pre>