Manikavelu Velayutham

Manikavelu Velayutham

  • 252
  • 7.6k
  • 2.5m

Concatenation of Strings LINQ vs For Loop, Where the execution will be faster ?

Oct 7 2010 12:47 AM

For Loop for concatenation of strings

 

foreach (int id in ints) 

        { 

            idString.Append(id + ", "); 

        } 

 

LINQ Query to concatenate a string

string ids = ints.Select(query => query.ToString()).Aggregate((a, b) => a + ", " + b); 
 
Performance wise which one will be faster. I searched through many websites, mostly they say LINQ has some performance implications like that, is that true or above LINQ query will execute faster.


Answers (5)