title: Creating and using a custom List<T> in C#
body: <p>I am trying to use a customized List were I have added a few additional tools. I want to apply this list to a long list of customized classes that I have created. All of the classes have an ID number and some of the tools in the List use the ID. </p>
  
  <p>Here is a portion of my code that I am trying to use. I hope this help you understand my problem.</p>
  
  <pre><code>namespace Simple_Point_of _Sales_System
  {
      public class MyList&lt;T&gt; : List&lt;T&gt;
      {
          internal int SetID()
          {
              return this.Max(n =&gt; n.ID) + 1;
          }
          internal T Find(int ID)
          {
              return this.Find(n =&gt; n.ID == ID);
          }
          internal T Add(T n)
          {
              Read();
              Add(n);
              Write();
              return n;
          }
          internal void Remove(int ID)
          {
              Read();
              if (this.Exists(t =&gt; t.ID == ID)) RemoveAll(t =&gt; t.ID == ID);
              else MessageBox.Show(GetType().Name + " " + ID + " does not exist.", "Missing Item", MessageBoxButtons.OK, MessageBoxIcon.Error);
              Write();
          }
          internal void Edit(int ID, T n)
          {
              Read();
              if (this.Exists(t =&gt; t.ID == ID)) this[FindIndex(t =&gt; t.ID == ID)] = n;
              else MessageBox.Show(GetType().Name + " " + ID + " does not exist.", "Missing Item", MessageBoxButtons.OK, MessageBoxIcon.Error);
              Write();
          }
          internal MyList&lt;T&gt; Read()
          {
              Clear();
              StreamReader sr = new StreamReader(@"../../Files/" + GetType().Name + ".txt");
              while (!sr.EndOfStream)
                  Add(new T().Set(sr.ReadLine()));
              sr.Close();
              return this;
          }
          internal void Write()
          {
              StreamWriter sw = new StreamWriter(@"../../Files/" + GetType().Name + ".txt");
              foreach (T n in this)
                  sw.WriteLine(n.ToString());
              sw.Close();
          }
      }
  
      public class Customer
      {
          public int ID;
          public string FirstName;
          public string LastName;
      }
  
      public class Item
      {
          public int ID { get; set; }
          public string Category { get; set; }
          public string Name { get; set; }
          public double Price { get; set; }
      }
  
      public class MyClass
      {
          MyList&lt;Customer&gt; Customers = new MyList&lt;Customer&gt;();
          MyList&lt;Item&gt; Items = new MyList&lt;Item&gt;();
      }
  }
  </code></pre>