Many of the new Linq features seem rather unknown:
Any<T>() & All<T>()
if( myCollection.Any( x => x.IsSomething ) )
ToList<T>(), ToArray<T>(), ToDictionary<T>()
var newDict = myCollection.ToDictionary( x => x.Name, x => x.Value );
First<T>(), FirstOrDefault<T>()
return dbAccessor.GetFromTable( id ). FirstOrDefault();
Where<T>()
//instead of foreach( Type item in myCollection ) if( item.IsValid ) //do stuff //you can also do foreach( var item in myCollection.Where( x => x.IsValid ) ) //do stuff //note only a simple sample - the logic could be a lot more complex
All very useful features that can be used outside of Linq syntax.
Keith Jan 06 '09 at 17:07 2009-01-06 17:07
source share