Posts

Linq: FirstOrFallback

Sometimes you want to use FirstOrDefault, but the default value of T is a valid value that might get returned. If you used FirstOrDefault, you wouldn’t know whether the value that you got is a valid first or the default fallback. I use FirstOrFallback to explicitly specify which fallback value I want, rather than always use default(T):… You can read the copy of the original post, or if that goes down too, you can try the Wayback Machine’s copy of it.
2008-04-23
1 min read

Linq Extensions Release 2 Now on CodePlex

I’ve updated my long standing Linq Extensions project on CodePlex to .NET 3.5 RTM and added the latest extension methods…. You can read the copy of the original post, or if that goes down too, you can try the Wayback Machine’s copy of it. Context: This post was automatically imported from my old blog, which was originally hosted on Microsoft’s ASP.NET Community Blogs. When they shut it down, I dumped all of my old posts to Wordpress.
2008-04-23
1 min read

Linq: The Missing ToDictionary Extension Method Overload

Enumerating over a Dictionary<TKey, TValue> you will get structs of type KeyValuePair<TKey, TValue>. Whenever you use the ToDictionary extension method, you are forced to specify how to get the key and value for each item, even if it’s an enumeration of KeyValuePairs. Seems a bit redundant, doesn’t it?… You can read the copy of the original post, or if that goes down too, you can try the Wayback Machine’s copy of it. Context: This post was automatically imported from my old blog, which was originally hosted on Microsoft’s ASP.
2008-04-22
1 min read