Friday, January 18, 2013

Linq performance with Count() and Any()

Recently I was using resharper to refactor some of my code and found that it was suggesting to use any() extension method instead of count() method in List<T>. I was really keen about performance and found that resharper was right. There is huge performance difference between any() and count() if you are using count() just to check whether list is empty or not.

Difference between Count() and Any():


In Count() method code will traverse all the list and get total number of objects in list while in Any() will return after examining first element in the sequence. So in list where we have many object it will be significant execution time if we use count().
Share:

How to get N row from datatable in C#

Problem:


Recently one of my friend was needed only first three rows of data table and so he asked me and I have multiple solutions for that. So thought it would be great idea to share with you guys.

Possible Solutions to problem:


There are two ways to solve this problem.
  1. With normal for loop
  2. With lamda expression and linq

1. With normal for loop:

Following is code from where we can get 3 rows of data table.
Share:
Thursday, January 17, 2013

New Milestone for Dotnetjalps.com-500000 visits for my blog

Today I got great news from sitemeter.com that my blog http://www.dotnetjalps.com completed 500,000 visitors for my blog. This is a new milestone achieved for this blog and I would like to thank all my blog readers for making this blog this much bigger.

On this occasion I would like to thanks all supporters, friends and my family members who have faith in me and believe that I could do something and this all because of them and my blog readers.
Followings are my statistics for my blog.
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews