Linq: FirstOrFallback

2008-04-23
1 min read

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.

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. You can still check out the original blog on the Wayback Machine.