Skip to content

Instantly share code, notes, and snippets.

@CalvinRodo
Created September 22, 2012 14:52
Show Gist options
  • Save CalvinRodo/3766423 to your computer and use it in GitHub Desktop.
Save CalvinRodo/3766423 to your computer and use it in GitHub Desktop.
Imports System.Runtime.CompilerServices
Module DBNullExtensions
<Extension()>
Public Function Coalesce(of T as {New})(obj as Object, alt as T) as T
If (obj is DBNull.Value) Then
return alt
End If
Return Cast(obj, T)
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment