title: Generic class where T : Class clarification
body: <p>There are semi answer to this question which I have read through thoroughly, as well as all things MSDN about generic classes but I am still having trouble when a generic class inherits from another class: <code>where T: ClassName</code></p>
  
  <p>For example, here is my generic list class</p>
  
  <pre><code>public class MyGenericList2&lt;T&gt; where T : Person
  {
      private T[] list;
  
      public MyGenericList2(int size)
      {
          list = new T[size];
      }
  
      public T getItem(int index)
      {
          T temp = default(T);
          temp = list[index];
          return temp;
      }
  
      public void setItem(int index, T value)
      {
          list[index] = value;
      }
  
      public void DisplayList()
      {
          for (int i = 0; i &lt; list.Length; i++)
          {
              Console.Out.WriteLine(list[i]);
          }
      }
  }
  </code></pre>
  
  <p>It inherits from the person class:
  NOTE: It is shortened for clarity sake</p>
  
  <pre><code>public abstract class Person
  {
      protected string firstName;
  
      // Getters
      public string getFirstName()
      {
          return this.firstName;
      }
      public void setFirstName(string fname)
      {
          this.firstName = fname;
      }
  }
  </code></pre>
  
  <p>When I try to call it I get an error about trying to convert a string to a {namespace}.Person which I sort of get, in that I am trying to put a string into a 'Person' box, but how does one call the class using this mechanism?</p>
  
  <p>Here is the main method</p>
  
  <pre><code>public static void Main(string[] args)
  {
      MyGenericList2&lt;Person&gt; studentGeneric = new MyGenericList2&lt;Person&gt;(3);
      Student st1 = new Student();
  
      st1.setFirstName("Thor");
      studentGeneric.setItem(0, st1); //This does not work
      studentGeneric.setItem(1, Person.setFirstName("Odin"); // Does not work
      studentGeneric.setItem(2, st1.setFirstName("Slepnir"); // Does not work
      studentGeneric.DisplayList();
      Console.ReadLine();
  }
  </code></pre>
  
  <p>If I cut out the <code>Where T : Person</code> and use <code>GenericList2&lt;string&gt;</code> it works fine, which makes sense since it is string to string.</p>
  
  <p>Any help would be appreciated</p>
  
  <p>quick clarification Student inherits from Person:</p>
  
  <pre><code>public class Student : Person
  {
  
      // Student 1
      private string studentID01 = "001";
  
      public string getStudentID01()
      {
          return this.studentID01;
      }
  }
  </code></pre>