Re: Complex if statement.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1ee746e4eb77eec798d201@xxxxxxxxxxxxxxxxxxxxxxx
Mike Schilling <ap@xxxxxxxxxxxxxxxx> wrote:

"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in
message news:ufG4U2ChGHA.3956@xxxxxxxxxxxxxxxxxxxxxxx
Arne,

No, in C#, logical expressions short circuit themselves if it can
not
effect the result.

To be precise, the operators && and || short-circuit. The operators &
and
|, which can also be used in logical expressions [1], do not.

1. Note that this is different from C, C++, and Java, in which & and |
are
bitwise operators only.

Not sure where you get that idea about Java from:

public class Test
{
public static void main(String[] args)
{
boolean a = true;
boolean b = false;

System.out.println (a&b);
}
}

I'll be damned. I stand correct:ed: boolean & and | are exactly the same in
Java as in C#. But in all the hundreds of thousands of lines of Java I've
read through, I don't recall ever seeing them used.


.



Relevant Pages

  • Re: Complex if statement.
    ... No, in C#, logical expressions short circuit themselves if it can not ... boolean b = false; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Do I have to close all streams from Process Class after using the Process object?
    ... I have to use Process proc = Runtime.getRuntime.execmethod to ... When I traced Java source code, ... My question is do I have to close all these streams ... runtime, final boolean strongRef, final boolean weakRef, final ...
    (comp.lang.java.programmer)
  • Re: About Javas Collection
    ... WHY does Java was designed like this, ... boolean contains ... reasonable to ask if an object not proven to be of type E is a member. ... The deeper answer to your "WHY" is that generics were not ...
    (comp.lang.java.programmer)
  • Re: Interupting the current thread
    ... public class StoppableThread extends Thread { ... * @param interrupt ... public void gentleStop (boolean interrupt, ... http://mindprod.com Java custom programming, consulting and coaching. ...
    (comp.lang.java.help)
  • Re: Rubys lack of variable declarations : Good or Bad?
    ... I recently wrote a small package in Java that parses and fetches ... If you are changing lFlag from a boolean to an integer, ... A static language will make it easer ... What interface does that parameter have to support? ...
    (comp.object)