Because it helps me to write compact and clean code of course !

For example, I need to expose a property that gives the number of visible items in my ViewModel.

Old way:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
        public int VisibleItemsCount
        {
            get
            {
                int i = 0;
                foreach (var item in this.Items)
                {
                    if (item.IsVisible)
                        i++;
                }
                return i;
            }
        }

Linq way:

?View Code CSHARP
1
2
3
4
5
6
7
public int VisibleItemsCount
{
    get
    {
        return this.Items.Count(item => item.IsVisible);
    }
}

Which one do you prefer ?