title: C# display generic array
body: <p>I'm trying to learn C# generic and I cannot seem to be able to display elements inside the array.  When i debug the code, I could see the elements if I expand the node employee.  However when I try to display it, it just prints out the class name instead of actual elements.  Please look below.</p>
  
  <pre><code>public class PrintArray&lt;T&gt;
  {
      public void OutputGeneric(T[] employee)
      {
          for (int i = 0; i &lt; employee.Length; i++)
          {
              Console.Write("\n" + employee[i]);//I can't access to FullName and Salary
          }
      }
  }
  
  public class Employee
  {
      private string Name;
      private int Income;
  
      public string FullName
      {
          set { Name = value;}
          get { return Name; }
      }
  
      public int Salary
      {
          set { Income = value; }
          get { return Income; }
      }
  }
  
  
  class Program
  {
      static void Main(string[] args)
      {
          PrintArray&lt;Employee&gt; pa = new PrintArray&lt;Employee&gt;();
  
          Console.Write("\n\Employee: ");
          Employee[] customArray = new Employee[3];
          customArray[0] = new Employee()
          {
              FullName = "John Doe",
              Salary = 100000
          };
          customArray[1] = new Employee()
          {
              FullName = "Mary Jane",
              Salary = 50000
          };
          customArray[2] = new Employee()
          {
              FullName = "Tyler Smith",
              Salary = 80000
          };
  
          pa.OutputGeneric(customArray);
  
          Console.ReadLine();
      }
  }
  </code></pre>