Created
July 12, 2010 21:28
-
-
Save cleydson/473087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Protected Function RetornaValor(ByVal valor As Object, Optional ByVal retornoPadrao As String = "") As String | |
If IsDBNull(valor) Then | |
Return retornoPadrao | |
Else | |
Return valor | |
End If | |
End Function | |
'ou | |
'Usando Generics | |
Public Shared Function RetornaValor(Of T)(ByVal valor As T, ByVal valorPadrao As T) As T | |
If IsDBNull(valor) Then | |
Return valorPadrao | |
Else | |
Return valor | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Função simples que verifica se o valor retornado do banco (ado.net) é null. Se for null retorna o valor padrão.