A
Andy Fish
Can Someone explain why this snippet doesn't work in C# 2.0:
Foo foo = new Foo();
List<Foo> lf = new List<foo>( { foo } );
whereas this works:
Foo foo = new Foo();
Foo[] af = { foo };
List<Foo> lf = new List<foo>( af );
It seems to me that the expression { foo } returns an array of Foo with only
one element in it, which should therefore be acceptable as IEnumerable<Foo>
to be passed into the generic list constructor.
TIA
Andy
Foo foo = new Foo();
List<Foo> lf = new List<foo>( { foo } );
whereas this works:
Foo foo = new Foo();
Foo[] af = { foo };
List<Foo> lf = new List<foo>( af );
It seems to me that the expression { foo } returns an array of Foo with only
one element in it, which should therefore be acceptable as IEnumerable<Foo>
to be passed into the generic list constructor.
TIA
Andy