Re: Complex if statement.
- From: "Mike Schilling" <ap@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 00:34:35 -0700
"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.
.
- Follow-Ups:
- Re: Complex if statement.
- From: Jon Skeet [C# MVP]
- Re: Complex if statement.
- References:
- Re: Complex if statement.
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Complex if statement.
- From: Mike Schilling
- Re: Complex if statement.
- From: Jon Skeet [C# MVP]
- Re: Complex if statement.
- Prev by Date: Re: Question about webBrowser
- Next by Date: Re: How to get a chart title from a worksheet cell in c#?
- Previous by thread: Re: Complex if statement.
- Next by thread: Re: Complex if statement.
- Index(es):
Relevant Pages
|