Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use of question mark in parameters
Message
De
07/11/2011 13:57:42
 
 
À
07/11/2011 11:38:25
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01528240
Message ID:
01528291
Vues:
42
J'aime (1)
I started to write an extension method to replace all the cases (Date, double, bool, integer, etc) when I came across this http://msdn.microsoft.com/en-us/library/3d6d4f1d.aspx

So instead of testing HasValue, you can simply use something like
  xx =  tdValue.GetValueOrDefault()

or 

 xx = tdValue.GetValueOrDefault(oApp.GetEmptyDate())
>
>Ok, thanks, BTW, I have this:
>
>
>        ' Avoid to receive a null
>        ' expD1 Value
>        Public Function GetNonNullable(ByVal tdValue As Date?) As Date
>            Dim ldValue As Date = Nothing
>
>            ' If we have a value
>            If tdValue.HasValue Then
>                ldValue = tdValue
>            Else
>                ldValue = oApp.GetEmptyDate()
>            End If
>
>            Return ldValue
>        End Function
>
>        ' Avoid to receive a null
>        ' expN1 Value
>        Public Function GetNonNullable(ByVal tnValue As Double?) As Double
>            Dim lnValue As Double = 0
>
>            ' If we have a value
>            If tnValue.HasValue Then
>                lnValue = tnValue
>            End If
>
>            Return lnValue
>        End Function
>
>        ' Avoid to receive a null
>        ' expL1 Value
>        Public Function GetNonNullable(ByVal tlValue As Boolean?) As Boolean
>            Dim llValue As Double = False
>
>            ' If we have a value
>            If tlValue.HasValue Then
>                llValue = tlValue
>            End If
>
>            Return llValue
>        End Function
>
>        ' Avoid to receive a null
>        ' expN1 Value
>        Public Function GetNonNullable(ByVal tnValue As Integer?) As Integer
>            Dim lnValue As Integer = 0
>
>            ' If we have a value
>            If tnValue.HasValue Then
>                lnValue = tnValue
>            End If
>
>            Return lnValue
>        End Function
>
>        ' Avoid to receive a null
>        ' expC1 Value
>        Public Function GetNonNullable(ByVal tcValue As String?) As String
>            Dim lcValue As Integer = ""
>
>            ' If we have a value
>            If tcValue.HasValue Then
>                lcValue = tcValue
>            End If
>
>            Return lcValue
>        End Function
>
>
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform