Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of question mark in parameters
Message
From
09/11/2011 10:07:34
 
 
To
07/11/2011 21:21:23
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01528240
Message ID:
01528483
Views:
43
>Or make an Extension Method so the usage is more fluent:
>
>
>   if (!tcValue.IsNullOrEmpty())
>   {
>       lcValue = tcValue;
>   }
>


I like that Mike ... don't know why I didn't think of making that an Extension method! Thanks!

~~Bonnie


>
>>I'd use the string.IsNullOrEmpty() method instead:
>>
>>
>>        Public Function GetNonNullable(ByVal tcValue As String) As String
>>            Dim lcValue As String= ""
>>
>>            ' If we have a value
>>            If Not string.IsNullOrEmpty(tcValue) Then
>>                lcValue = tcValue
>>            End If
>>
>>            Return lcValue
>>        End Function
>>
>>
>>~~Bonnie
>>
>>
>>>>In String you need to omit ?. String is not a simple type like integer, for example. So, you can pass null without declaring string?, just declare parameter as string.
>>>
>>>So, the adjustment I made is this:
>>>
>>>
>>>        ' 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 Not tcValue Is DBNull.Value Then
>>>                lcValue = tcValue
>>>            End If
>>>
>>>            Return lcValue
>>>        End Function
>>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform