none
LINQ Vs ForEach Loop which one better in performance and other thing also RRS feed

  • Question

  •  

    Hi,

    i was using LINQ and for it seems better in performance then foreach loop, but recently i found one article there they mention in other way

    so i wanted to know which one better in performance , do we have test where we can test and see how to do.

    below article said foreach better then LINQ, i want to clear my doubt.?

     

     

    Monday, October 31, 2011 1:52 PM

Answers

  • Hi,

    LINQ is also calling foreach to loop, it is a extention method with IEnumerable type which records in memory.

    If you are doing LINQ to SQL or Entity Framework, the LINQ query will be translate to T-SQL, so the performance is good.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jumpingboy Monday, November 14, 2011 9:05 PM
    Wednesday, November 2, 2011 9:16 AM
    Moderator

All replies