LINQ in Action

So i was stuck in different link strategies so i thought i should share with you my finding.

Below are some common operations and off course LINQ is far powerful than that.

var d = new Dictionary<int, int>();
d.Add(-1,0);
d.Add(0,0);
d.Add(1,0);
d.Add(8,0);
d.Add(9,0);
d.Add(10,0);
d.Add(11,3);
d.Add(12,5);
d.Add(13,1);
d.Add(14,0);
d.Add(15,0);
d.Add(16,0);
d.Add(17,0);
d.Add(18,1);
d.Add(19,0);

//get the minimum value = 0
var value = d.Select(s => s.Value).Min( );

//Get the minimum value but it should be greater then 0 = 1
value = d.Select(s => s.Value).Where(x=>x>0).Min( );

//add all the values which are greater then 1 = 8
value = d.Select(s => s.Value).Where(x => x > 1).Sum();

//get the minimum key = -1
value = d.Keys.Min( );

//get the max key where the value is greater then zero = 18
value = d.Select(s => s).Where(k => k.Value > 0).ToDictionary(s => s.Key, f => f.Value).Keys.Max( );

//count the number of keys which has zero value = 11
value = d.Select(s=>s).Count(k => k.Value == 0);