title: c# Referencing a class instance from a list using a value of a property as the index
body: <p>How do I construct the Lst class so I can reference specific instances by a property of the class?  If it isn't possible in a List is it possible in an Lst[] array?  Does creating/using/referencing a list in this pattern have a name?</p>
  
  <p>The error I get is <code>Argument 1: cannot convert from 'string' to 'int'</code>
  on the two l["..List"] inside the Console.WriteLine()</p>
  
  <pre><code>namespace ConsoleApplication1 {
  
      public class Lst {
          public string Name;
          public Lst(string Name) { this.Name = Name; }
          public Lst this[string Name] { get { return this[Name]; } }
      }
  
      class Program {
          static void Main(string[] args) {
              List&lt;Lst&gt; l = new List&lt;Lst&gt;();
              l.Add(new Lst("1stList"));
              Console.WriteLine("List {0}:", l["1stList"].Name);
              Console.WriteLine("List {0}:", l["2ndList"].Name);
              Console.ReadKey();
          }
      }
  }
  </code></pre>