|
|
|
I do not understand the message!
|
|
|
|
|
See the thread posted just before yours.
|
|
|
|
|
Looking over the link, it seems to actually indicate that they are equivalent.
|
|
|
|
|
If you see some of the comments, which I agree with, the extra capabilities of the List seems to be the deciding factor for many.
|
|
|
|
|
[ramble]
Regardless, I still have a sense of distrust when using Linq, and I'd be rather loathe to use it for large (more than a few hundred) records, and I imagine that if the expression (if your processing data from a database) will still run considerably faster in native SQL on the database server itself. Plus, debugging those IEnumerable<T> and friends collections is rather impossible unless they're converted to List<T> first. The debugger definitely needs to be more helpful! That said, Linq (and lambda expressions) are definitely very sexy for certain things!
[/ramble]
Marc
|
|
|
|
|
I try to keep to the LINQ Enumerable, but definitely do not like it. The advantage and disadvantage of the LINQ Enumerable is that the LINQ statement is only executed when it is needed; That can cut down memory, and processing. Of course working with them in the debugger can be painful since you have to physically cause the LINQ to be executed with the Expand results. Also, after a while can no longer even get the LINQ to execute. I therefore will sometime convert to a List when programming so that debugging is easier, and when I am finished, convert back. I have also found that I need to convert to a List when working with EntityFramework because errors cause once out of the Object Context. I also have found that working with WPF binding, it can be advantageous to go with a List.
|
|
|
|
|
It makes sense that if theres an array and a list of the same type that there would be some additional overhead because of the added benefits of the List type. I like that linq gets rid of my for loops with lots of nested if statements.
I have been using resharper from jetbrains.com to rewrite my for loops with nested if statements and boolean logic to LINQ and now I can write my own basic lambda expressions and im finding more uses every day.
|
|
|
|
|
I think most experienced programmers really like LINQ. It definately cuts down on a lot of code. However, and you have obviously learned, there is a significant learning curve. I have also learned a lot from resharper.
|
|
|
|
|
if data will be changed later (insert,update,or delete) you prefer to use ToList().
|
|
|
|
|
Obviously a ToList is a lot more flexible. Since the performance is slightly greater as a small cost in memory, ToList seems to be the better choice, even if you will not be needing to make any changes. I can think of very few times it is worth do ToArray.
|
|
|
|