Equivalent VB.Net code for Bitwise Inclusive OR Operator (|) in CS

G

Guest

What is the equivalent VB.net code for Bitwise Inclusive OR Operator (|) in
CSharp?

Example what is the equivalent VB.net code for the following CSharp.net code?

dwFlags = CRYPTPROTECT_LOCAL_MACHINE|CRYPTPROTECT_UI_FORBIDDEN;
 
D

Damien

Chrysan said:
What is the equivalent VB.net code for Bitwise Inclusive OR Operator (|) in
CSharp?

Example what is the equivalent VB.net code for the following CSharp.net code?

dwFlags = CRYPTPROTECT_LOCAL_MACHINE|CRYPTPROTECT_UI_FORBIDDEN;

dwFlags = CRYPTPROTECT_LOCAL_MACHINE Or CRYPTPROTECT_UI_FORBIDDEN

Yup, confusingly, the Or operator is for both logical and bitwise Or
operations.

Damien
 
N

Nick Hall

Damien said:
dwFlags = CRYPTPROTECT_LOCAL_MACHINE Or CRYPTPROTECT_UI_FORBIDDEN

Yup, confusingly, the Or operator is for both logical and bitwise Or
operations.

Damien
This is not quite correct. Or is the bitwise operator as you say; OrElse is
the logical operator.

Regards,

Nick Hall
 
C

CT

This is not quite correct. Or is the bitwise operator as you say; OrElse
is the logical operator.

No, OrElse is used for shortcurcuiting the logical evaluation. Or is also a
logical operator.
 
G

Guest

Both VB and C# have bitwise operators which also are used as
non-short-circuiting operators:
"Or" and "And" in VB
| and & in C#

The short-circuiting operators:
"OrElse" and "AndAlso" in VB
|| and && in C#

The corresponding logical operators in each language behave identically in
each language.

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant C++: C# to C++ Converter
Instant J#: VB.NET to J# Converter
 
N

Nick Hall

Comments inline...

CT said:
No, OrElse is used for shortcurcuiting the logical evaluation. Or is also
a logical operator.

Um yes, OrElse can be used for shortcircuiting because it is a logical
operator. The || operator in C# works in exactly the same way.
Any bitwise operator can also be used as a logical operator when the
operands are boolean (after all False has all the bits switched off and True
has all the bits switched On). Or certainly HAS been used as a logical
operator in prior versions of VB since it was the only option - and it still
can. OrElse is now the more correct option to use.Nick Hall
 
C

CT

OrElse is now the more correct option to use.

Nice catch, although I don't necessarily agree. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top