Click here to Skip to main content
15,887,477 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Logic PinPopular
Shameel17-May-11 8:44
professionalShameel17-May-11 8:44 
GeneralRe: Logic Pin
Fabio V Silva17-May-11 8:47
Fabio V Silva17-May-11 8:47 
GeneralRe: Logic Pin
Shameel18-May-11 0:44
professionalShameel18-May-11 0:44 
GeneralRe: Logic Pin
musefan19-May-11 3:23
musefan19-May-11 3:23 
GeneralRe: Logic Pin
Liju Sankar25-May-11 3:42
Liju Sankar25-May-11 3:42 
GeneralRe: Logic Pin
agolddog25-May-11 3:51
agolddog25-May-11 3:51 
GeneralRe: Logic Pin
dchrno25-May-11 4:02
dchrno25-May-11 4:02 
GeneralRe: Logic Pin
Jason Christian25-May-11 7:13
Jason Christian25-May-11 7:13 
http://msdn.microsoft.com/en-us/library/aa691306%28v=vs.71%29.aspx[^]

This (from Microsoft) includes & and | in the logical operators.

And semantics aside, they can and sometimes should be used as such in C# - for those cases where you want a logical operator without short-circuiting (i.e. one of the operands is a method call with side-effects - which would be a whole nother type of questionable practice, but the language allows it and it has is uses). So in that sense the OP is correct, & and && do the same thing except && short-circuits.

Of course, they don't do exactly the same thing, because & can also be used on non-boolean types as a bitwise operator. So (4 & 5) is meaningful, whereas 4 && 5 is not.
GeneralRe: Logic Pin
Shameel17-May-11 7:56
professionalShameel17-May-11 7:56 
GeneralRe: Logic Pin
hairy_hats25-May-11 0:59
hairy_hats25-May-11 0:59 
GeneralRe: Logic Pin
Mel Padden26-May-11 21:06
Mel Padden26-May-11 21:06 
GeneralRe: Logic Pin
Keith Barrow18-May-11 4:52
professionalKeith Barrow18-May-11 4:52 
GeneralRe: Logic Pin
gumi_r@msn.com17-May-11 7:08
gumi_r@msn.com17-May-11 7:08 
GeneralRe: Logic Pin
Fabio V Silva17-May-11 7:49
Fabio V Silva17-May-11 7:49 
GeneralRe: Logic Pin
Shameel17-May-11 7:52
professionalShameel17-May-11 7:52 
GeneralRe: Logic Pin
Shameel17-May-11 8:10
professionalShameel17-May-11 8:10 
GeneralRe: Logic [modified] PinPopular
gumi_r@msn.com18-May-11 23:35
gumi_r@msn.com18-May-11 23:35 
GeneralRe: Logic Pin
0bx18-May-11 21:05
0bx18-May-11 21:05 
GeneralRe: Logic PinPopular
AspDotNetDev17-May-11 11:02
protectorAspDotNetDev17-May-11 11:02 
GeneralRe: Logic Pin
Fabio V Silva17-May-11 11:30
Fabio V Silva17-May-11 11:30 
GeneralRe: Logic Pin
Quirkafleeg20-May-11 4:39
Quirkafleeg20-May-11 4:39 
GeneralRe: Logic PinPopular
_Erik_18-May-11 3:45
_Erik_18-May-11 3:45 
GeneralRe: Logic Pin
Fabio V Silva18-May-11 4:09
Fabio V Silva18-May-11 4:09 
GeneralRe: Logic Pin
_Erik_18-May-11 4:29
_Erik_18-May-11 4:29 
GeneralRe: Logic Pin
Keith Barrow18-May-11 5:03
professionalKeith Barrow18-May-11 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.