I’m sure most programmers are familiar with Linq, and agree with me that it’s great. I personally really enjoying using Linq, mostly in the form o f Linq to SQL and Linq to Objects. It also helps with simplifying your code and makes it easier to read. Some of the most useful Linq functions I find are FirstOrDefault, Any, All and Where. However sometimes I still come across developers writing loops to do work when Linq can be utilized to simplify it. So here are some simple code samples on how to use Linq to eliminate writing foreach loops.