I have a statement that I am using two NOT operators.
can this be simplified using a 'andalso'?
VB Code:
If Not rs.BOF And Not rs.EOF Then
VB Code:
If Not rs.BOF AndAlso rs.EOF Then
Printable View
I have a statement that I am using two NOT operators.
can this be simplified using a 'andalso'?
VB Code:
If Not rs.BOF And Not rs.EOF Then
VB Code:
If Not rs.BOF AndAlso rs.EOF Then
I think both will do.
cool. I thought so but reading in the msdn confused me a TAD lol
it says that if the first expression evaluates to false, the second is considered false. in my case, the evaluation would be negated with that NOT operator. I dont like using NOT but I am converting some vb6 code another developer had.
thanks!!
I don't think that the AndAlso will have any effect on the Not operator. The difference between And and AndAlso is that And will evaluate both parts of the expression even if the first part is false, whereas AndAlso will skip to the next instruction if the fist part is false. So all it does is improve performance a little bit.
I think C# uses AndAlso by default right?
I would assume so... if its modeled after Java... but then again, its basically the same as using:Quote:
Originally posted by PT Exorcist
I think C# uses AndAlso by default right?
VB Code:
If x = True Then If y = True Then 'do something z=True End If End If
or
VB Code:
If (x AndAlso y) Then z=True
Code://C#
If (x && y)
//do something
z=true;