CrashTECH wrote:
Haven't used LINQ. Not sure I am a fan of dropping that stuff right in the middle of my code.
Well, LINQ is an umbrella term. LINQ can be used for collections.
Code:
//return a subset of ints in the list
int[] myInt = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var anInt = myInt.Where(x => x >= 2 && x <= 9);
List<int> listOfInts = anInt.ToList();
//return the first element in the list
int[] myInt = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var anInt = myInt.Where(x => x >= 2 && x <= 9).FirstOrDefault();
int thisInt = anInt;
It makes finding things inside collections (anything that implements IEnumerable and IQueryable) easier. The examples above do no justice but a good primer on it.
Highly recommended. I use LINQ pretty much exclusively now, it makes writing a Data Access Layer easier and if you use LINQ to SQL, it will generate business objects for you.
