Hi Rakesh,
It depends. For ex: for a simple
for-each
loop, using LINQ is not necessary, instead it can give more overhead. But using
for-each
where you want to add additional filtering and grouping, then it will be slow, it would be better to use a LINQ query in such conditions.
That was about Linq to Objects. Considering the case where you want to use Linq to Sql, I would like to recommend this 5-part series article regarding the performance of Linq to SQL :
http://blogs.msdn.com/b/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx[
^].
About Linq to XML, I'm not sure about the performance but its very easy to create
XmlElement
compared to the functionality provided by
XmlDocument
class. Its also easy to traverse and filter through the XML, also it has support to XPath expression using the
XPathNavigator
.
:)