title: Getting the lowest value of a List<Struct.int>
body: <p>I've got a <code>struct</code> which contains a few <code>int</code> and <code>bool</code> members, and I'm looking to obtain the lowest value from the list (actually making an A* Search based Path Finder).</p>
  
  <p>Basically, my object looks like this:</p>
  
  <pre><code>    public struct Tile
      {
          public int id;
          public int x;
          public int y;
          public int cost;
          public bool walkable;
          public int distanceLeft;
          public int parentid;
      }
  </code></pre>
  
  <p>And I want to get the item with the lowest distanceLeft. The list is declared like so:</p>
  
  <pre><code>        List&lt;Structs.Tile&gt; openList = new List&lt;Structs.Tile&gt;();
  </code></pre>
  
  <p>And values are assigned in this manner:</p>
  
  <pre><code>        while (pathFound == null)
          {
              foreach (Structs.Tile tile in map)
              {
                  foreach (Structs.Tile tile1 in getSurroundingTiles(Current))
                  {
                      if (tile1.x == tile.x &amp;&amp; tile1.y == tile.y)
                      {
                          Structs.Tile curTile = tile1;
                          curTile.parentid = Current.id;
                          curTile.distanceLeft = (Math.Abs(tile.x - goalx) + Math.Abs(tile.y - goaly));
                          if (curTile.distanceLeft == 0)
                          {
                              pathFound = true;
                          }
                          openList.Add(curTile);
                      }
                  }
              }
              foreach (Structs.Tile tile in openList)
              {
  
              }
          }
  </code></pre>
  
  <p>If I had to guess I'd say this is either very difficult or far more complex than I'm making it sound, or incredibly easy and I'm just confused.</p>
  
  <p>I did think about scrolling through the list and comparing each item to its lower counterpart, but that seems unreasonable considering the age we're in, it just seems there would be a simpler way. I don't care for the order of the list, as I am assigning each item an index from which I can call it.</p>
  
  <p>Thanks in advance!</p>