Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is Empty or Null
Message
From
19/03/2008 15:42:50
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01303548
Message ID:
01303588
Views:
16
>>>>Would you not better use and AND instead of an OR ?
>>>>
>>>>>
>>>>> if ((this.lsbUsers.SelectedItem != null &&  this.lsbUsers.Text != string.Empty)
>>>>>            && this.LsbRoles.SelectedValue != null)
>>>>
>>>>I think the best thing to do is to always test for null first
>>>
>>>I think you're right here, that when we need to test for negatives we need to use AND instead of OR.
>>>
>>>I'll try that first and see, if it would resolve the problem.
>>>
>>>If not, I appreciate future comments on the exact method in question.
>>>
>>>UPDATE. Nope, no cigar.
>>___
>>
>>Ok, I was too quick to answer.
>>
>>Why not set a breakpoint preceeded with
>>
>>// if in vs2005 replace var by bool
>>
>>var selnull = this.lsbUsers.SelectedItem != null;
>>var textempty = this.lsbUsers.Text != string.Empty;
>>var lsbrolesnull = is.LsbRoles.SelectedValue != null;
>>
>>// put the break here
>>// examine the 3 variables
>>
>>// your if( statement follows
>>if ((this ....
>>
>>
>
> bool TestUser = (this.lsbUsers.SelectedItem == null);
> bool TestUserText = (this.lsbUsers.Text == null);
> bool TestRole = (this.LsbRoles.SelectedValue == null) ;
>
>All evaluated to false even if I don't select anything in the Roles listbox.

Then - dunno - check your if statement. There must be a reason. It's just that I do not see it
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform