Thoughts and Rants

My random thoughts and rants on things

Getting the site back in shape

I have not been keeping my web site up to date for quite a while.  Recently I moved it from my old hosting provider to a new one and I am going to try to get it updated and start moving content from the old pages into the new framework.  So bear with me and I will see if I can get this puppy back into shape.

Dave

LINQ is your friend

I have been writing code for a fair amount of time and until very recently I was on the fence about LINQ.  Recently I picked up a project that relied heavily on the use of LINQ to retrieve data from IEnumerable types.  After a few non-starts for me I quickly realized the power of LINQ.  For example I used to do this:

List<MyObj> myList = new List<MyObj>();
MyObj myObj = null;

foreach( var _obj in myList )
{
    if( string.Compare(_obj.ItemName, "SomeName", true) == 0 )
    {
        MyObj = _obj;
        break;
    }
}

With LINQ, I can do this:

List<MyObj> myList = new List<MyObj>();
MyObj myObj = null;

myObj = myList.Where( o => o.ItemName == "SomeName" ).FirstOrDefault();

So LINQ has finally won me over.