title: C# Programming: Maintaining a List that Associates an ID with Information Quickly
body: <p>In a game that I've been working on, I created a system by which the game polls a specific 'ItemDatabase' file in order to retrieve information about itself based on a given identification number.  The identification number represented the point in the database at which the information regarding a specific item was stored.  The representation of every item in the database was comprised of 162 bytes.  The code for the system was similar to the following:</p>
  
  <pre><code>// Retrieves the information about an 'Item' object given the ID.  The 
  // 'BinaryReader' object contains a file stream to the 'ItemDatabase' file.
  public Item(ushort ID, BinaryReader itemReader)
  {
      // Since each 'Item' object is represented by 162 bytes of information in the 
      // database, skip 162 bytes per ID skipped.
      itemReader.BaseStream.Seek(162 * ID, SeekOrigin.Begin);
  
      // Retrieve the name of this 'Item' from the database.
      this.itemName = itemReader.ReadChars(20).ToString();
  }
  </code></pre>
  
  <p>Normally there wouldn't be anything particularly wrong with this system as it queries the desired data and initializes it to the correct variables.  However, this process must occur during game time, and, based on research that I've done about the efficiency of the 'Seek' method, this technique won't be nearly fast enough to be incorporated into a game.  So, my question is: What's a good way to maintain a list that associates an identification number with information that can be accessed quickly?</p>