3.5 SP1. Just copied it over to VS2010 (why haven't i upgraded yet!?) and it
worked like you said.

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Michael Minutillo
Sent: Thursday, 12 August 2010 6:50 PM
To: ozDotNet
Subject: Re: converting List<T> into IEnumerable<InterfaceT>

 

Hi Wal,

 

What version of the framework are you using. In .NET 4, both work fine.

 

Regards,


Michael M. Minutillo
Indiscriminate Information Sponge
Blog: http://wolfbyte-net.blogspot.com



On Thu, Aug 12, 2010 at 4:31 PM, Wallace Turner <w.tur...@fex.com.au> wrote:

Hi,

Assume the class definitions

interface IOrder { }

class Order : IOrder { }

 

I understand why this doesn't compile:

 

var list = new List<Order>();

IEnumerable<IOrder> iOrders = list; //IEnumerable<IOrder> not same type as
List<Order>!

 

So using that logic, can't understand why this *does* compile:

 

var arr = new Order[0];

IEnumerable<IOrder> iOrders = arr; //IEnumerable<IOrder> assignable from
Order[] ?

 

Cheers,

 

Wal

 

Reply via email to