title: Casting array to IEnumerable<T>
body: <p>Assume you have a basic <code>Employee</code> class as such:</p>
  
  <pre><code>class Employee
  {
     public string Name;
     public int Years;
     public string Department;
  }
  </code></pre>
  
  <p>Then (in a seperate class) I have the following code fragments (I think i understand all but the last):</p>
  
  <p>I believe that the following code fragment works because the array initiliser creates an array of Employee objects which are the same type as the workforce variable being assigned to.</p>
  
  <pre><code>Employee[] workforceOne = new Employee[] {
     new Employee() { Name = "David", Years = 0, Department = "software" },
     new Employee() { Name = "Dexter", Years = 3, Department = "software" },
     new Employee() { Name = "Paul", Years = 4, Department = "software" } };
  </code></pre>
  
  <p>I then have the following code fragment.  I believe this works because the array of <code>Employee</code> objects implicity is an implementation of the Array() class which implements <code>IEnumerable</code>.  Therefore, I believe this is why the array can be assigned to IEnumerable?</p>
  
  <pre><code>IEnumerable workforceTwo = new Employee[] {
     new Employee() { Name = "David", Years = 0, Department = "software" },
     new Employee() { Name = "Dexter", Years = 3, Department = "software" },
     new Employee() { Name = "Paul", Years = 4, Department = "software" } };
  </code></pre>
  
  <p>Then I have this code fragment:</p>
  
  <pre><code>IEnumerable&lt;Employee&gt; workforceThree = new Employee[] {
     new Employee() { Name = "David", Years = 0, Department = "software" },
     new Employee() { Name = "Dexter", Years = 3, Department = "software" },
     new Employee() { Name = "Paul", Years = 4, Department = "software" } };
  </code></pre>
  
  <p><strong>I am not sure why this code fragment works?</strong>  <code>IEnumerable&lt;Employee&gt;</code> inherits from <code>IEnumerable</code> (and overrides (or overloads?) the <code>GetEnumerator()</code> method) but shouldn't i therefore need a cast for the above to work as such:</p>
  
  <pre><code>//The cast does work but is not required
  IEnumerable&lt;Employee&gt; workforceFour = (IEnumerable&lt;Employee&gt;)new Employee[] {
     new Employee() { Name = "David", Years = 0, Department = "software" },
     new Employee() { Name = "Dexter", Years = 3, Department = "software" },
     new Employee() { Name = "Paul", Years = 4, Department = "software" } };
  </code></pre>
  
  <p>It seems that the array is being implicitly down cast from a type of <code>IEnumerable</code> to <code>IEnumerable&lt;Employee&gt;</code> but I always thought when you needed to convert a type to something more specific you needed an explicit cast.</p>
  
  <p>Maybe i'm missing something simple in my understanding here but can someone please help me with my understanding around this.</p>
  
  <p>Thank you.</p>