Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of question mark in parameters
Message
From
07/11/2011 11:32:45
 
 
To
07/11/2011 11:29:52
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:
01528259
Views:
32
>>>>>>I'd say it means that tdNullable can be null http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx#Y1537
>>>>>>
>>>>>>You may want to test tdNullable.HasValue to verify whether it contains a value
>>>>>
>>>>>Is there a way to avoid this question mark if there is a possiblity to receive a null value for the parameter?
>>>>
>>>>
>>>>try
>>>>
>>>>Private Function GetNonNullable(ByVal tdNullable As Nullable(Of Date)) As Date
>>>>
>>>
>>>Hence the ? is easier!
>>
>>
>>I know that - but if one wants to avoid the ?
>
>You can't. DateTime cannot contain null. DateTime? can. In your method, however, you'll want to check it:
>
>
>   void MyMethod(datetime? value)
>   {
>     if(value.HasValue())
>     {
>         DoSomethingElse(value.Value); //passes in the value as DateTime type
>     }
>     ...
>   }
>
Re read my answer
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform