LINQ THINK
Posted by: Peter Brombergs UnBlog,
on 13 Aug 2010 |
View original | Bookmarked: 0 time(s)
The more I use LINQ, the more I run into legacy code that can easily be improved. The nice thing about LINQ is that it can make your code more elegant and easier to understand, as well as, in most cases, more efficient.
Lets take a simple example. Here Ive extracted some legacy code in the form of a method that tells you if a given string Key is present in a string array. First, the OLD way:
//"OLD" way:
static bool IsKeyInArray(string[] items, string key)
{
if (items == null) return false;
if...